Google Maps API 同步地理编码 [英] Google Maps API Geocode Synchronously
问题描述
我想知道是否可以使用 googlemaps api 同步地对某些内容进行地理编码,因此它不是等待回调函数被调用,而是等待一个值被返回.有没有人找到一种方法来做这样的事情.
I was wondering if its possible to geocode something using googlemaps api synchronously so instead of waiting for a callback function to be called, it would wait for a value to be returned. Has anyone found a way to do something like this.
P.S.:我使用的是第 3 版的 api
P.S.: I'm using version 3 of the api
推荐答案
Geocoder 使用该值调用您的回调函数.这是唯一的方法.如果它是同步的,您的脚本将在等待地理编码处理时冻结.真的没有任何理由这样做.
The Geocoder calls your callback function with the value. That's the only way to do it. If it were synchronous, your script would freeze while it waited for the Geocode to process. There really isn't any reason to do it like that.
你到底想完成什么?
这篇关于Google Maps API 同步地理编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!