为什么我的谷歌地图总是不居中?

时间:2012-01-05 09:41:08

标签: javascript google-maps jquery-mobile

虽然我可以显示,但我的setcenter /指针始终位于左侧位置0,0。 为什么会这样?

我有没有做错的事情? 欢呼声。

function initializeGMap() {
    if (GBrowserIsCompatible()) {
        document.getElementById("map_canvas").style.width = $('#gmap').width() + "px";
        document.getElementById("map_canvas").style.height = $('#gmap').height() + "px";
        var map = new GMap2(document.getElementById("map_canvas"));
        var malllat = localStorage.getItem("malllat");
        var malllon = localStorage.getItem("malllon");
        var point = new GLatLng(malllat, malllon);
        var marker = new GMarker(point);
        map.addControl(new GSmallMapControl());
        map.addOverlay(marker);
        map.setCenter(point, 16);
    }
}


<div data-role="page" id="gmap">
    <div id="mapheader" data-role="header" data-theme="b">
        <a href="#mall" class="getLocalStorage" data-icon="back" data-transition="none">Back</a>
        <h1>Google Map</h1>
    </div>
    <!--div id="map_canvas" style="width: 480px; height: 480px"></div-->
        <div id="map_canvas"></div>
</div>

0 个答案:

没有答案