How to prompt user for place using Google Maps in javascript?

送分小仙女□ 提交于 2019-12-06 15:02:53

问题


I am new to Google Maps and still new to Javascript. I need to have a user select a location on a map (using Google Map) and retrieve the corresponding town, country, latitude and longitude. If timezone is available too, that would be great.

I can't find an operational code example. Does anyone have one to share? Thanks.


回答1:


The sample code provided by Google at http://code.google.com/apis/maps/documentation/javascript/examples/event-arguments.html gets a LatLng from a mouse click and puts a marker on a map. (Just view the source code to see the sample code.)

The sample code provided by Google at http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-reverse.html takes a latitude and longitude and determines the location via reverse geocoding. (Again, view source code to see the sample.)

Sounds like your functionality is basically parts of each of those samples and fusing them.

You might want to check out the Events documentation and the Reverse Geocoding documentation if you run into any problems (or even if you don't).



来源:https://stackoverflow.com/questions/8306836/how-to-prompt-user-for-place-using-google-maps-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!