2016-08-05 3 views
0

私は開発サイトでビンマップとAPIを追加しましたが、コードを受け入れる方法を理解する助けが必要ですライブ緯度と経度の座標を更新して、これらの値に関連して私の地図にマーカーを更新させてください。私のビングマップにリアルタイムの緯度および経度座標を受け入れ、マップに沿って私のアスリートを追跡する方法

現在のところこれは私が持っているものですが、コードの一部はgoogleをgoogleに置き換えたもので、マイクロソフトとベストを願っています。

私はBing MapsのV8チームは、実際にここに正確にこれを行う方法の文書化されたコードのサンプルを持っている

<!DOCTYPE html> 
<html> 
<head> 
    <title>Geolocation</title> 
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> 
    <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario' async defer></script> 
</head> 
<body> 
    <div id='printoutPanel'></div> 

    <div id='myMap' style='width: 400px; height: 400px;'></div> 
    <script type='text/javascript'> 

     // Setting boundary and loading map 
     function loadMapScenario() { 
      var bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(29.332823, -81.492279), new Microsoft.Maps.Location(28.435825, -81.622231)); 
      var map = new Microsoft.Maps.Map(document.getElementById('myMap'), { 
       credentials: 'Bing Maps Key', 
       maxBounds: bounds 
      }); 

      // Highlighting the border of bounds on the map 
      var boundsBorder = new Microsoft.Maps.Polyline([bounds.getNorthwest(), 
       new Microsoft.Maps.Location(bounds.getNorthwest().latitude, bounds.getSoutheast().longitude), 
       bounds.getSoutheast(), 
       new Microsoft.Maps.Location(bounds.getSoutheast().latitude, bounds.getNorthwest().longitude), 
       bounds.getNorthwest()], { strokeColor: 'red', strokeThickness: 2 }); 
      map.entities.push(boundsBorder); 
     } 
    </script> 

    <script> 
     function getReverseGeocodingData(lat, lng) { 
      var latlng = new Microsoft.maps.LatLng(lat, lng); 
      // This is making the Geocode request 
      var geocoder = new Microsoft.maps.Geocoder(); 
      geocoder.geocode({ 'latLng': latlng }, function (results, status) { 
       if (status !== Microsoft.maps.GeocoderStatus.OK) { 
        alert(status); 
       } 
       // This is checking to see if the Geoeode Status is OK before proceeding 
       if (status == Microsoft.maps.GeocoderStatus.OK) { 
        console.log(results); 
        var address = (results[0].formatted_address); 
       } 
      }); 
     } 
    </script> 

答えて

関連する問題