locked
Ploting polyline on google map RRS feed

  • Question

  • User400674434 posted

    Hi, I am new to Asp.net, I need to plot polyline on google map using the list of lat long from database please anyone can help me to do this..............

    Friday, November 7, 2014 2:46 AM

Answers

  • User281315223 posted

    The Google Maps Javascript API has a variety of features relating to actually drawing on the maps themselves using coordinates from within your maps. You may want to check out the Drawing section, in particular the section on handling shapes and lines : 

    The Developer API site itself provides a variety of examples demonstrating each of the major objects that you can draw such as the one seen for drawing a line below : 

    // This example creates a 2-pixel-wide red polyline showing
    // the path of William Kingsford Smith's first trans-Pacific flight between
    // Oakland, CA, and Brisbane, Australia.
    
    function initialize() {
      var mapOptions = {
        zoom: 3,
        center: new google.maps.LatLng(0, -180),
        mapTypeId: google.maps.MapTypeId.TERRAIN
      };
    
      var map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);
    
      var flightPlanCoordinates = [
        new google.maps.LatLng(37.772323, -122.214897),
        new google.maps.LatLng(21.291982, -157.821856),
        new google.maps.LatLng(-18.142599, 178.431),
        new google.maps.LatLng(-27.46758, 153.027892)
      ];
      var flightPath = new google.maps.Polyline({
        path: flightPlanCoordinates,
        geodesic: true,
        strokeColor: '#FF0000',
        strokeOpacity: 1.0,
        strokeWeight: 2
      });
    
      flightPath.setMap(map);
    }
    
    google.maps.event.addDomListener(window, 'load', initialize);

    Since it is just relying on Javascript, you shouldn't encounter any issues at all with using it in your ASP.NET applications.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 8, 2014 8:49 AM