How do I add Google Maps on my site?

前端 未结 2 919
花落未央
花落未央 2021-01-20 18:46

I have a form and I want to add a \"select location\" option.

How can I do this, and how can I place a pin as the selected location?

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-20 19:11

    You may want to consider using the Google Maps API, as davek already suggested.

    The following example may help you getting started. All you would need to do is to change the JavaScript variable userLocation with the location chosen by your users from the drop-down field you mention.

    
     
     
         
        Google Maps API Demo 
         
       
       
    
        

    The above example would render a map like the one below:

    Render google map in based on selected location

    The map will not show if the Google Client-side Geocoder cannot retreive the coordinates from the address.

提交回复
热议问题