在谷歌地图上显示所有搜索到的位置结果


Show all searched location result on google map

我正在使用谷歌地图创建一个web应用程序。我需要知道如何实现,当我使用php搜索某个位置并在php array()中得到结果时,包含不同位置坐标(经纬度)的数组结果显示在地图上+在地图视图中关注这些坐标。。。。。

您需要创建一个GBound,并在稍后使用extend()方法创建时为其提供所有点数。https://developers.google.com/maps/documentation/javascript/v2/reference#GBounds

然后使用map.fitBounds()方法设置这些点上的视图。https://developers.google.com/maps/documentation/javascript/reference

如果您不需要滚动地图,请使用Google静态地图API:https://developers.google.com/maps/documentation/staticmaps/

<img>标记添加到HTML中,源代码格式如下:https://maps.googleapis.com/maps/api/staticmap?center=LAT,LONG&amp;zoom=14&amp;size=288x200&amp;sensor=false"

这将返回以您指定的坐标为中心的地图图像。