I have polygons loaded using method
map.data.loadGeoJson('geo.json',{ idPropertyName: 'ID' });
Now I want to make editable one of loaded from geojson polygons.
I was tried:
map.data.getFeatureById(1).setProperty('editable', true);
But it seems that data.feature don't have editable property?
Any ideas how to make it in easiest way? Only one idea that I have in this moment is to make my own parser from geoJson and draw all shapes as google.maps.Polygon().
To download your data, head to Google Maps on your computer and sign in. Next, click the three-line menu icon in the top-left corner next to the Search box. Near the bottom, select “Your Data in Maps.” On the next screen, scroll down to and select “Download Your Maps Data.”
With the Data layer, you can add GeoJSON data to a Google map in just one line of code. map. data. loadGeoJson('google.
Maybe it isn't best solution but it works for me now. I'm duplicating shape geometry from feature and creating new polygon in place.
var shape = [];
for (var i = 0; i < map.data.getFeatureById(ID).getGeometry().getLength(); i++) {
var shapeData = map.data.getFeatureById(ID).getGeometry().getAt(i).getArray();
shape.push(shapeData);
}
nowEditingShape = new google.maps.Polygon({
paths: shape,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
editable: true
});
map.data.remove(map.data.getFeatureById(ID));
nowEditingShape.setMap(map);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With