2012-03-27 179 views
2

我需要谷歌地图才能加载,因此标记偏离中心位置,换句话说,地图中心不在中心位置,而是位于右侧。我希望这是有道理的。移动谷歌地图中心

这是来自我正在使用的脚本。

function setCenterCoords($lon,$lat) { 
    $this->centerLatitude = (float) $lat; 
    $this->centerLongitude = (float) $lon; 
} 

我该怎么做才能让中心显示在页面的右侧2/3而不是在页面中间?谢谢

回答

6

使用方法setCenter(latlng),因为你需要将地图。

+1

谢谢。我是新来的。这是来自我正在使用的脚本。 ($ lon,$ lat){ $ this-> centerLatitude = $ this-> centerLongitude =(float)$ lon; } 我该怎么做才能让中心显示在页面的右侧2/3而不是中间?谢谢 – bobudell 2012-03-27 21:49:09

+1

如果这个(或其他)回答你的问题,我建议你['接受它](http://meta.stackexchange.com/a/5235)作为答案。 – 2012-10-03 18:29:47

0

由于谷歌地图API文档的说明,假设你使用JavaScript API,你可以设置中心在地图选项:

https://developers.google.com/maps/documentation/javascript/tutorial#MapOptions

+2

谢谢。我是新来的。这是来自我正在使用的脚本。函数setCenterCoords($ lon,$ lat){$ this-> centerLatitude =(float)$ lat; $ this-> centerLongitude =(float)$ lon; }我该怎么做才能让中心显示在页面的正确2/3而不是中间?谢谢 – bobudell 2012-03-27 21:51:14