yenbao1340 / gmaps-utility-library-dev

Automatically exported from code.google.com/p/gmaps-utility-library-dev
0 stars 0 forks source link

Stop/Restart SnapToRoute #83

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is a feature/enhancement proposal for SnapToRoute.

It would be nice to have the ability to stop and restart SnapToRoute
updating the marker position. I added two functions "stop" and "restart"
and made the necessary changes to the existing code. Please feel free to
review the changes and incorporate them into the release.

Regards
Matias Fernandez

Original issue reported on code.google.com by pisco.ch on 26 Jan 2009 at 8:55

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by pamela.fox on 26 Jan 2009 at 8:56

GoogleCodeExporter commented 8 years ago
Nicely done. I've checked the code, and i think you missed the zoomend 
listener, ill
be testing the code in a bit, see how it handles itself.

Original comment by bbr...@gmail.com on 26 Jan 2009 at 9:55

GoogleCodeExporter commented 8 years ago
Committed in revision 899.

Original comment by bbr...@gmail.com on 26 Jan 2009 at 10:31

GoogleCodeExporter commented 8 years ago
Hello

I didn't miss the "zoomend" listener. Consider this case:
1. You have a SnapToRoute that handles the marker.
2. You call stop on your SnapToRoute object.
3. You zoom in or out.
4. You reactivate by calling restart on your SnapToRoute object.

If you remove the zoomend listener, "loadLineData_" will not be called. When 
you reactivate snapping to the route, the 
"routePixels_" will be out of sync with the polyline at the current zoom level.
Additionally I noticed strange behaviour after zooming and reactivating if I 
removed the zoomend listener.
Last but not least, if you zoom in it may seem as if the marker is not on the 
route because of inaccuracies of the 
polyline at the previous zoom level.

I would recommend keeping the zoomend listener registered :-)

Regards
Matias Fernandez

Original comment by pisco.ch on 26 Jan 2009 at 7:06

GoogleCodeExporter commented 8 years ago
Hi again

I quickly set up an example.

The in the first example I keep the "zoomend" listener registered:
http://pisco.ch/temp/gmap/snaptoroute/example1.html

In the second example I deregister the listener just as you did:
http://pisco.ch/temp/gmap/snaptoroute/example2.html

I'm sorry this is not a minimal example, didn't have time to strip out all the 
unnecessary parts.

Regards
Matias Fernandez

Original comment by pisco.ch on 26 Jan 2009 at 8:14

GoogleCodeExporter commented 8 years ago
Sorry to bother you again. May I suggest adding a call to

this.updateMarkerLocation_(this.marker_.getLatLng());

at the end of SnapToRoute.prototype.loadLineData_? Otherwise, if you stopped 
snapping and zoom in, the 
marker will be off the road. Observe the effect at:

http://pisco.ch/temp/gmap/snaptoroute/example3.html

I used SnapToRoute.js from r900.

Regards
Matias

Original comment by pisco.ch on 28 Jan 2009 at 10:18