标签: google-maps google-geocoder
如果我使用谷歌地图地理编码器找到地址的一点 - 我通常在建筑物的中间(屋顶)得到一个点
示例:
https://maps.google.com/maps?q=350+Alabama+Street,+San+Francisco,+CA,+United+States&hl=en&ll=37.764842,-122.412077&spn=0.001497,0.002661&sll=37.794661,-122.425718&sspn=0.001496,0.002661&oq=350%2BAlabama%2BStreet&hnear=350+Alabama+St,+San+Francisco,+California+94110&t=m&z=19
Geocoder请求:
http://maps.googleapis.com/maps/api/geocode/json?address=350+Alabama+Street+San+Francisco&sensor=false
所以这一点实际上是在哈里森和阿拉巴马州的街道中间
但我需要得到一个位于阿拉巴马街线的点
有没有办法做到这一点?
答案 0 :(得分:2)
您可以请求DirectionsService而不是地理编码,当与google.maps.TravelMode.DRIVING一起使用时,这应该返回街道上的位置
google.maps.TravelMode.DRIVING
https://maps.google.com/maps?saddr=350+Alabama+Street,+San+Francisco,+CA,+United+States&daddr=Alabama+St&hl=en&sll=37.764829,-122.412369&sspn=0.001043,0.002411&geocode=Fco-QAIdXiG0-ClZY3r_L36PgDG0YXVKn8-9fQ%3BFe4-QAIdrCK0-A&oq=350+Alabama+Street,+San+Francisco,+CA,+United+States&mra=dme&mrsp=1&sz=19&t=m&z=19