Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps v3 data.feature Editable?

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().

like image 834
seek Avatar asked Apr 28 '14 13:04

seek


People also ask

How do I get data from Google Maps?

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.”

How do I load a GeoJSON file into Google Maps?

With the Data layer, you can add GeoJSON data to a Google map in just one line of code. map. data. loadGeoJson('google.


1 Answers

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);
like image 174
seek Avatar answered Oct 09 '22 01:10

seek