Limit marker movement from starting point (google maps API 3) -



Limit marker movement from starting point (google maps API 3) -

i place marker on map draggable property true. want restrict moving marker not more 500 meters original position. how can it? there improve way tried?

i tried drag event. measure distance code found on so. don't know how can prevent drag. seek returning false, seek view if function parameter has cancel or that.

google.maps.event.addlistener(marker, 'drag', function(e) { var distance = application.getmapdistance(data[0].geometry.location, marker.getposition()); document.title = distance; if (distance > 500) homecoming false; //not working, e has no cancel or });

edit:

apparently not happy question. yes basic logic set google marker position lastly good, way, marker flicker when moved outside bounds. pretty sure google can improve this.

google.maps.event.addlistener(marker, 'drag', function(e) { var distance = application.getmapdistance(data[0].geometry.location, marker.getposition()); document.title = distance; if (distance > 500) marker.setposition(lastgoodposition); else lastgoodposition = marker.getposition(); });

google-maps google-maps-api-3

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -