2016-08-05 1 views
0

Je viens d'ajouter des cartes bing et API à mon site de développement mais j'ai besoin d'aide pour comprendre comment accepter mon code mise à jour en direct lat et longues coordonnées et ma carte mettre à jour le marqueur en ce qui concerne ces valeurs.Comment faire pour que mes cartes bing acceptent les coordonnées lat et long en temps réel et suivent mon athlète en direct sur la carte

Actuellement, c'est ce que j'ai, mais une partie du code a été conçu pour google maps que j'ai remplacé les mots google avec Microsoft en espérant le meilleur.

S'il vous plaît être doux Je suis nouveau au codage

<!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> 

Répondre