【发布时间】:2017-12-21 09:57:21
【问题描述】:
在我的网络应用程序中,我使用的是 gmap javascript API (https://developers.google.com/maps/documentation/javascript/)。一旦用户按下按钮,我将在函数中使用下面的代码来定位/居中 gmap。
var position = new google.maps.LatLng(lat, lng);
map.setCenter(position);
此代码使用纬度和经度。我想根据给定的关键字定位/居中 gmap,而不是纬度和经度。例如,如果输入是“Paris”,我如何定位/居中 gmap?
【问题讨论】:
-
您可以使用google maps geocoding API获取所需城市的纬度/经度
标签: javascript jquery html google-maps google-maps-api-3