How retrieve latitude and longitude via Google Maps API?

前端 未结 8 1905
粉色の甜心
粉色の甜心 2020-12-23 15:12

How retrieve latitude and longitude via Google Maps API?

8条回答
  •  眼角桃花
    2020-12-23 15:45

    To add to RedBlueThing's answer you can do stuff like:

    geocoded_by :address
    
    def address
     [street, city, state, country].compact.join(', ')
    end
    

    to help you narrow down the exact location, otherwise if you just send in the street the geocoder gem just returns the first instance of that street it finds which could be anywhere in the world

提交回复
热议问题