问题
this question is an extension to the question on Finding particular cities along your Path but am including all the details.
google.maps.geometry.poly.isLocationOnEdge(LatLngOfDbCoordinate,new google.maps.Polyline({path:google.maps.geometry.encoding.decodePath(response.routes[0].overview_polyline)}),0.00001);
1) can i run this above line of code for many(eg:10000) (LatLngOfDbCoordinate stored in the database) at the server side as javascript inside the php code with Node.JS ?
2)if yes then could you please tell how should i go about it else
3)could you please tell me how to execute this code via php or with some other classes like http://luktek.com/Blog/2011-02-03-google-maps-routeboxer-in-php (from the stack overflow link at the top)?
And could you please tell me how to use isLocationOnEdge() function with the routeboxer class mentioned above?
4)Is there any other easier way to use isLocationOnEdge() or any other method at the server side to which i am not aware of ?
5) Is there any usage limits to use the function isLocationOnEdge() on server side ? As this is the function of the geometry library and i would only be using this functions boolean return values to display the coordinates which are on/near the polyline are usage limits applicable?
6)And would it be useful to store the overview polyline of routes in the db(cause can be very lengthy in case of large routes) or should i make a request everytime to google url service by sending them start and destination coordinates and using the overview polyline which i recieve as JSON or XML to pass in isLocationOnEdge()? Please specify the reason.
Please Help
Thanks in advance
回答1:
I had the same problem. But as my application was in android only with the server side is in nodejs, decided to make the implementation in android. I used the PolyUtil class that has the same functions.
http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/PolyUtil.html
But if you really need implement this code in javascript server side you can try to recreate the functions of PolyUtil class. In it you will find the complete code of isLocationOnEdge
https://github.com/jefersondeoliveira/android-hackathon/blob/master/google-maps-utils/library/src/com/google/maps/android/PolyUtil.java
Hope this helps.
bye
来源:https://stackoverflow.com/questions/26345758/how-to-use-islocationonedge-function-to-find-coordinates-on-near-a-path-of-googl