How to prompt user for place using Google Maps in

2019-04-16 04:58发布

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条回答
Fickle 薄情
2楼-- · 2019-04-16 05:31

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).

查看更多
登录 后发表回答