javascript - Removing a particular polygon from maps data -


i generating polygons using addgeojson method not sure how can remove particular polygon later when needed. here code

var __layers;  var layer = new google.maps.data();         $.ajax({             url: url,             type: 'post',             success:function(data) {                 __layers = layer.addgeojson(data);                 layer.setmap(map1);                 layer.setstyle(style);             }         }); 

i trying remove data not working

map1.data.remove(__layers[0]); 

the way _layers has been initialized looks culprit here. may either try layer.setmap(null) or modify code following

var __layers = [];  var layer = new google.maps.data();         $.ajax({             url: url,             type: 'post',             success:function(data) {                 __layers.push(layer.addgeojson(data));                 layer.setmap(map1);                 layer.setstyle(style);             }         }); 

and use

map1.data.remove(__layers.pop()); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -