set polygon ontop KML layer?

38 visningar
Hoppa till det första olästa meddelandet

Thoern

oläst,
20 maj 2011 06:45:592011-05-20
till Google Maps JavaScript API v3
I use a draw polygon by insertin nodes as below.
But when having a KML layer in the map the KML layer is ontop the
polygon..

How do you change to make the polygon sit ontop the KML?

Is it just a question of creating a new instance of the kml layer
BEFORE the polygon in the
"Initialize map function"? or is this some native behavior?


poly = new google.maps.Polygon({
strokeWeight: 3,
fillColor: '#5555FF'
});
poly.setMap(map);
poly.setPaths(new google.maps.MVCArray([path]));

google.maps.event.addListener(map, 'click', addPoint);
}

function addPoint(event) {
path.insertAt(path.length, event.latLng);

var marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable: true
});
markers.push(marker);
marker.setTitle("#" + path.length);

google.maps.event.addListener(marker, 'click', function() {
marker.setMap(null);
for (var i = 0, I = markers.length; i < I && markers[i] !=
marker; ++i);
markers.splice(i, 1);
path.removeAt(i);
}
);

google.maps.event.addListener(marker, 'dragend', function() {
for (var i = 0, I = markers.length; i < I && markers[i] !=
marker; ++i);
path.setAt(i, marker.getPosition());
}
);
}

Thoern

oläst,
23 maj 2011 07:20:582011-05-23
till Google Maps JavaScript API v3
Here is an example:

The polygons created end up below the KML.

Anybody have any ideas to set the newly created polygon ontop of KML?

EXAMPLE:
1 klick in the map to add a node
2 klick on a node to remove it
3 drag a node to move a node.

http://www.chalmersmotorklubb.se/google/draw.htm

Thoern

oläst,
24 maj 2011 10:38:292011-05-24
till Google Maps JavaScript API v3
there we go, it was just an issue af running a polygon.setmap(map) at
the right sequence
Did not think it was as simple as that.

Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden