You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to change the color of a ColorLayer after a click event. But when I do it the color is not updating for some zoom positions.
I made an exemple to reproduce this behaviour based en the globe_vector.html example.
<html><head><title>Itowns - Globe + color layers from vector data</title><metacharset="UTF-8"><linkrel="stylesheet" type="text/css" href="css/example.css"><linkrel="stylesheet" type="text/css" href="css/loading_screen.css"><metaname="viewport" content="width=device-width, initial-scale=1.0"><scriptsrc="js/GUI/dat.gui/dat.gui.min.js"></script></head><body><divid="viewerDiv" class="viewer"></div><divstyle="position: absolute; top: 0; right: 0;"><buttononclick="colorAriege()">Color Ariege</button></div><scriptsrc="js/GUI/GuiTools.js"></script><scriptsrc="../dist/itowns.js"></script><scriptsrc="js/loading_screen.js"></script><scriptsrc="js/FeatureToolTip.js"></script><scripttype="text/javascript">// # Simple Globe viewer/* global itowns, setupLoadingScreen, GuiTools, ToolTip */// Define initial camera positionvarpositionOnGlobe={longitude: 3.5,latitude: 44,altitude: 1000000};// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)varviewerDiv=document.getElementById('viewerDiv');// Instanciate iTowns GlobeView*varview=newitowns.GlobeView(viewerDiv,positionOnGlobe);varmenuGlobe=newGuiTools('menuDiv',view);setupLoadingScreen(viewerDiv,view);// Add one imagery layer to the scene// This layer is defined in a json file but it could be defined as a plain js// object. See Layer* for more info.itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function_(config){config.source=newitowns.WMTSSource(config.source);varlayer=newitowns.ColorLayer('Ortho',config);view.addLayer(layer).then(function_(){menuGlobe.addLayerGUI.bind(menuGlobe);itowns.ColorLayersOrdering.moveLayerToIndex(view,'Ortho',0);});});// Add two elevation layers.// These will deform iTowns globe geometry to represent terrain elevation.functionaddElevationLayerFromConfig(config){config.source=newitowns.WMTSSource(config.source);varlayer=newitowns.ElevationLayer(config.id,config);view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));}itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);varpromises=[];// Fetch, Parse and Convert by iTownsvarkmlSource=newitowns.FileSource({url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',projection: 'EPSG:4326',fetcher: itowns.Fetcher.xml,parser: itowns.KMLParser.parse,});varkmlLayer=newitowns.ColorLayer('Kml',{name: 'kml',transparent: true,source: kmlSource,});promises.push(view.addLayer(kmlLayer));// Parse and Convert by iTownspromises.push(itowns.Fetcher.xml('https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx').then(function_(gpx){vargpxSource=newitowns.FileSource({fetchedData: gpx,projection: 'EPSG:4326',parser: itowns.GpxParser.parse,});vargpxLayer=newitowns.ColorLayer('Gpx',{name: 'Ultra 2009',transparent: true,source: gpxSource,style: {stroke: {color: 'red',},point: {color: 'white',line: 'red',}},});returnview.addLayer(gpxLayer);}));// Convert by iTownspromises.push(itowns.Fetcher.json('https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson').then(function_(geojson){returnitowns.GeoJsonParser.parse(geojson,{buildExtent: true,crsIn: 'EPSG:4326',crsOut: view.tileLayer.extent.crs,mergeFeatures: true,withNormal: false,withAltitude: false,});}).then(function_(parsedData){varariegeSource=newitowns.FileSource({
parsedData,});varariegeLayer=newitowns.ColorLayer('ariege',{name: 'ariege',transparent: true,style: {fill: {color: 'orange',opacity: 0.5,},stroke: {color:'white',},},source: ariegeSource,});returnview.addLayer(ariegeLayer);}));// Listen for globe full initialisation eventview.addEventListener(itowns.VIEW_EVENTS.LAYERS_INITIALIZED,function_(){Promise.all(promises).then(newToolTip(view));});functioncolorAriege(){varlayer=view.getLayerById('ariege');layer.style.stroke.color='red';layer.style.fill.color='blue';view.notifyChange();}</script></body></html>
Try to zoom in/zoom out, you'll see that the Ariege layer stay yellow some times and take the new colour in some other zoom position.
Is this the right method to do something like this ?
m.
The text was updated successfully, but these errors were encountered:
Hi, this is totally normal as we don't rasterize a layer everytime we display it: we raster it one time only, and then it goes in the Cache.
However, it could be useful (like in your case) to be able to force the update of the rasterization. I see where we could add something to solve that, so maybe we can have this feature soon.
Hello,
using last version of Itown.
I try to change the color of a ColorLayer after a click event. But when I do it the color is not updating for some zoom positions.
I made an exemple to reproduce this behaviour based en the globe_vector.html example.
Try to zoom in/zoom out, you'll see that the Ariege layer stay yellow some times and take the new colour in some other zoom position.
Is this the right method to do something like this ?
m.
The text was updated successfully, but these errors were encountered: