KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have two geoJson layers being loaded - both layers are the same data for testing purposes, but being drawn from two different json files. When I turn the layers on and off in the layer controller, the draw order of the layers change. Any ideas why this is happening? I have put my code into a JSFiddle: http://jsfiddle.net/lprashad/ph5y9/10/ and the JS is below: //styling for watersheds_copy var Orange = { "color": "#ff7800", "weight": 5, "opacity": 0.65 }; var Water_Orange = L.geoJson(watersheds_copy, { style: Orange }); Water_Orange.addData(watersheds_copy); //these are blue var Water_blue = L.geoJson(watersheds, {}); Water_blue.addData(watersheds); //This sets the inital order - last in layer list being on top. Except minimal - tile layer is always on bottom var map = L.map('map', { center: [41.609, -74.028], zoom: 8, layers: [minimal, Water_Orange, Water_blue] }); var baseLayers = { "Minimal": minimal, "Night View": midnight }; //This controls the order in the layer switcher. This does not change draw order var overlays = { "Water_Orange": Water_Orange, "Water_blue": Water_blue }; L.control.layers(baseLayers, overlays).addTo(map); LP
Tags (comma-separated)
Save Edits
Cancel