Reputation: 317
I would like to show an info window when I'm moving a vertex on an editable polyline. This info will show the distance and heading to the prior vertex on the polyline. When I drop the vertex, the info window must be closed. The problem is polyline hasn't a drag event over vertex. I'll try with polyline's mousemove but It is fired after move has finished. In the next code, I show an example what I said. I have a polyline (flightPath). If I click on the last vertex I will like to move a marker at the same time. But It doesn't work. The marker is moved after movement is finished.
google.maps.event.addListener(flightPath, 'mousemove', function (event) {
if (typeof event.vertex === "undefined") {
moveline = 0
}
else {
if (event.vertex == (flightPath.getPath().getLength()-1)) {
var path = flightPath.getPath();
marker.setPosition(path.getAt(event.vertex));
}
}
});
Some suggestion?
Note: My polyline is editable.
Thanks
Upvotes: 0
Views: 1551
Reputation: 3
You could manage a drag end event on the marker and change de latLng of the vertex:
google.maps.event.addListener(marker, 'dragend', function(evt){
var vertex = marker.get('vertex');
var path = flightPath.getPath();
var newPath = Array.prototype.slice.call(path).filter(
function(element, index){
return index < vertex;
}).concat([evt.latLng],
Array.prototype.slice.call(path).filter(
function(element, index){
return index > vertex;
}));
flightPath.setPath(newPath);
});
I'm sorry for my bad english but i hope it helps.
Upvotes: 0