none
How to save roadname to database ? RRS feed

  • Question

  • From giving code I want to save roadname

                                                          

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title>Handle Location Disambiguation in Directions</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
          <script type="text/javascript">
          var map = null;
          var directionsManager;
          var directionsErrorEventObj;
          var directionsUpdatedEventObj;

          function getMap()
          {
              map = new Microsoft.Maps.Map(document.getElementById('myMap'), {credentials: 'AtAszL5x6VInNQaK0U-w2DlueXXFKuefQhIWcNNKK39n0NfGBfKr0ZcdFRye4UdZ'});
          }

          function createDirectionsManager()
          {
              var displayMessage;
              if (!directionsManager) 
              {
                  directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
                  displayMessage = 'Directions Module loaded\n';
                  displayMessage += 'Directions Manager loaded';
              }
              alert(displayMessage);
              directionsManager.resetDirections();
              directionsErrorEventObj = Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', function(arg) { handleDirectionsError(arg) });
              directionsUpdatedEventObj = Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', function() { alert('Directions updated') });
          }

          function handleDirectionsError(arg) {
            if (arg.responseCode == 12) {
              showDisambiguation(arg);
            }
            else {
              showDirectionsError(arg.message);
            }
          }

          function showDirectionsError(message) 
          {
            var displayString = "Event Info: Directions Error\n Message: " + message;
            alert(displayString);
          }

          function showDisambiguation(arg) {
            var stringToDisplay = "";
            var waypoints = directionsManager.getAllWaypoints();
            var i = 0;
            for (i = 0; i < waypoints.length; i++) {
              stringToDisplay += "<li><b>Waypoint " + (i + 1) + ":</b> " + waypoints[i].getAddress() + "</li>";
              var disambigResult = waypoints[i].getDisambiguationResult();
              if (disambigResult != null) {
                stringToDisplay += "<ol>";
                var j = 0;

                if (disambigResult.businessSuggestions.length > 0) {
                    for (j = 0; j < disambigResult.businessSuggestions.length; j++) {
                        var parameterString = "(" + i + ", " + j + ", 'business')";
                        stringToDisplay += "<li><a href=\"javascript:void(0);resolveDisambiguation" + parameterString + ";\">" +
                            disambigResult.businessSuggestions[j].name + "</a><BR>" +
                            disambigResult.businessSuggestions[j].address + "</li>";
                    }
                }
                else if (disambigResult.locationSuggestions.length > 0) {
                    for (j = 0; j < disambigResult.locationSuggestions.length; j++) {
                        var parameterString = "(" + i + ", " + j + ", 'location')";
                        stringToDisplay += "<li><a href=\"javascript:void(0);resolveDisambiguation" + parameterString + ";\">" +
                            disambigResult.locationSuggestions[j].suggestion + "</a></li>";
                    }
                }
                else {
                    stringToDisplay += disambigResult.headerText + "\n";
                }

                stringToDisplay += "</ol>";
              }
            }
            var itinerary = document.getElementById("directionsItinerary");
            if (!itinerary) {
              itinerary = document.createElement("div");
              itinerary.id = "directionsItinerary";
              document.body.appendChild(itinerary);
            }
            itinerary.innerHTML = "<ul>" + stringToDisplay + "</ul>";
            showDirectionsError("Disambiguation of waypoints required");
          }

          function resolveDisambiguation(waypointIndex, choiceIndex, disambiguationType) {
            clearItinerary();
            var currentWaypoints = directionsManager.getAllWaypoints();
            var disambiguationWaypoint = currentWaypoints[waypointIndex];
            var disambiguationResult = disambiguationWaypoint.getDisambiguationResult();
            if (disambiguationType == 'business') {
              disambiguationWaypoint.setOptions({ address: disambiguationResult.businessSuggestions[choiceIndex].address });
              var latitude = disambiguationResult.businessSuggestions[choiceIndex].location.latitude;
              var longitude = disambiguationResult.businessSuggestions[choiceIndex].location.longitude;
              disambiguationWaypoint.setOptions({ location: new Microsoft.Maps.Location(latitude, longitude) });
              disambiguationWaypoint.setOptions({ businessDetails: { businessName: disambiguationResult.businessSuggestions[choiceIndex].name} });
              disambiguationWaypoint.setOptions({ businessDetails: { phoneNumber: disambiguationResult.businessSuggestions[choiceIndex].phoneNumber} });
            }
            else {
              disambiguationWaypoint.setOptions({ address: disambiguationResult.locationSuggestions[choiceIndex].suggestion });
              var latitude = disambiguationResult.locationSuggestions[choiceIndex].location.latitude;
              var longitude = disambiguationResult.locationSuggestions[choiceIndex].location.longitude;
              disambiguationWaypoint.setOptions({ location: new Microsoft.Maps.Location(latitude, longitude) });
            }
            directionsManager.calculateDirections();
          }

          function clearItinerary() {
            var c = document.getElementById("directionsItinerary");
            c.innerHTML = "&nbsp;";
          }



          function locationDisambiguationExample()
          {
            if (!directionsManager) { createDirectionsManager(); }
            directionsManager.resetDirections();
            var ambiguousSunnyvaleWaypoint = new Microsoft.Maps.Directions.Waypoint({ address: 'Chiangmai University, Thailand;' });
            directionsManager.addWaypoint(ambiguousSunnyvaleWaypoint);
            var nonambiguousSunnyvaleWaypoint = new Microsoft.Maps.Directions.Waypoint({ address: 'Tha Phae Gate, Thailand' });
            directionsManager.addWaypoint(nonambiguousSunnyvaleWaypoint);

    // Set the element in which the itinerary will be rendered
            directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('directionsItinerary') });
    // Set Route Mode to driving 
            directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });

            alert('Calculating directions...');
            directionsManager.calculateDirections();
          }
    function createDirections()
          {
            if (!directionsManager)
            {
              Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: locationDisambiguationExample });
            }
            else
            {
              locationDisambiguationExample();
            }

          }
          </script>
       </head>
     <body onload="getMap();">
          <div id='myMap' style=" width:800px; height:600px;"></div>
          <div>
             <input type="button" value="Show Location Disambiguation" onclick="createDirections();" />
          </div>
    <div id='directionsItinerary'> </div> 


    <?php
    $objConnect = mysql_connect("localhost","root","");
    if($objConnect)
    {
    echo "Database Connected.";
    }
    else
    {
    echo "Database Connect Failed.";
    }

    mysql_close();

    ?>
    <body>
    </body>
    </html>

    This picture that I want to save

    http://www.uppic.org/image-178C_51134AD5.jpg

    Thank You

    Thursday, February 7, 2013 6:35 AM

Answers

  • Saving road names or any data from the Bing Maps services other than coordinates from the geocoding service is against the terms of use.

    http://rbrundritt.wordpress.com

    Thursday, February 7, 2013 5:03 PM