【问题标题】:How to set the center of the map with Javascript and Subgurim Maps如何使用 Javascript 和 Subgurim Maps 设置地图的中心
【发布时间】:2009-10-01 08:58:11
【问题描述】:

我想用 Javascript 设置地图的中心。

我只能找到一些带有标记的代码,但我想要客户端代码:

/* Server code */
GMap1.setCenter(latlng, zoomLevel, mapType  );

我想这样做(这是无效的代码:-))

<script>
    subgurim_GMap1.SetCenter(47.1, 2.3, 6)
</script>

其中 47.1 和 2.3 是纬度/经度,6 是缩放级别。

【问题讨论】:

    标签: google-maps subgurim-maps


    【解决方案1】:

    试试这个:

    map.setZoom(6);
    var point = new GLatLng(26.228595038041917, 50.54535984992981);
    map.setCenter(point);
    

    【讨论】:

    • 哇,真快!您是否也知道如何在 javascript 中获取当前的 lat/lng 和 zoomlevel?想用当前值设置一个cookie,以便他们以后可以去那个位置。
    • GMap1.getZoomLevel() 或 GMap2.getZoom()
    • 和 getCoordX() 和 getCoordY() 得到纬度/经度
    • 为了更简洁,跳过 'map.setZoom(6)' 而直接使用它:map.setCenter(point,6);
    • 对于像我这样一无所知的人,映射它是 gmap 的客户端名称:P 它可能是例如 foo-map
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 2014-01-10
    • 2016-09-03
    相关资源
    最近更新 更多