How to use Address instead of Lat/Long in Google Map API

前端 未结 2 1728
天命终不由人
天命终不由人 2020-12-22 12:15

I want to use Google Map Markers to mark the places where we provide our services. MY Code using Lat/Long is working Fine but in my Project i need to use City Names instead

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 12:55

    According to the spec (https://developers.google.com/maps/documentation/javascript/markers), you have to use a long/lat value to add a marker. However, you can use the Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/intro) to translate an address into a long/lat value. So basically your flow becomes:

    • geocode address x
    • take the result and use that in the marker

提交回复
热议问题