0

JQuery UI タブで Virtual Earth マップを遅延読み込みしようとしています。別のタブに Google マップもあります。私がやろうとしているのは、ユーザーがどちらかのマップを移動したときに、両方のマップが中心位置と一致するようにすることです。これが私が仮想地球側をやろうとしている方法です

var vemap;

//Lazy Load the Virtual Earth API
function loadMapControl() {
   var script = document.createElement("script");
   script.setAttribute("src", "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&onScriptLoad=initMap");
   script.setAttribute("type", "text/javascript");
   document.getElementsByTagName("head")[0].appendChild(script);
};

//Now load the Map 
function initMap() {
   var StartPoint = new  Microsoft.Maps.Location(currentLat, currentLng);
   vemap = new Microsoft.Maps.Map(document.getElementById("ve-map-canvas"), 
        {credentials:"<creds>", 
        center: StartPoint,
        zoom: gemap.getZoom(),
        mapTypeId: Microsoft.Maps.MapTypeId.birdseye,
        disableBirdseye:true,
        showMapTypeSelector:false});

    Microsoft.Maps.Events.addHandler(vemap, 'viewchangeend', veChanged);
};

function veChanged() {
    var localMap = this.target;
    var point = new GeoPoint(localMap.GetCenter().Longitude,    localMap.GetCenter().Latitude);
    $("#lat").val(point.getLatDeg());
    $("#lng").val(point.getLonDeg());
    $("#currentZoom").val(localMap.GetZoomLevel());
    currentLat = localMap.GetCenter().Latitude;
    currentLng = localMap.GetCenter().Longitude;
    currentZoom = localMap.GetZoomLevel();
};

Virtual Earth マップを中心に戻すと、veChanged イベントがトリガーされますが、localMap.GetCenter() は「Uncaught TypeError: undefined is not a function」で失敗します。vemap.GetCenter() も試しましたが、同じ結果が得られます。vemap にアクセスする方法について何か考えはありますか?

4

1 に答える 1

1

あなたの問題は、getCenter()代わりに間違った関数名 try を使用していることだと思いますGetCenter()。最初の文字が小文字であることに注意してください。

var point = new GeoPoint(localMap.getCenter().logitude, localMap.getCenter().latitude);

私が使用した他の識別子も最初の文字が小文字であることに注意してください。

于 2014-08-26T02:43:22.473 に答える