Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show custom lines on Google Map

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 208
    Comment on it

    Hello Reader's if you are integrating the Google Map in the website and you also want to show custom line on the map, Then this blog is very helpful you.
    Lets see the working of this custom map.

    <!DOCTYPE html>
    <html>
    <head>
    <script
    src="http://maps.googleapis.com/maps/api/js">
    </script>
    
    <script>
    var x=new google.maps.LatLng(52.395715,4.888916);
    var stavanger=new google.maps.LatLng(58.983991,5.734863);
    var amsterdam=new google.maps.LatLng(52.395715,4.888916);
    var london=new google.maps.LatLng(51.508742,-0.120850);
    
    function initialize()
    {
    var mapProp = {
      center:x,
      zoom:4,
      mapTypeId:google.maps.MapTypeId.ROADMAP
      };
    
    var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
    
    var myTrip=[stavanger,amsterdam,london];
    var flightPath=new google.maps.Polyline({
      path:myTrip,
      strokeColor:"#0000FF",
      strokeOpacity:0.8,
      strokeWeight:2
      });
    
    flightPath.setMap(map);
    }
    
    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    
    <body>
    <div id="googleMap" style="width:500px;height:380px;"></div>
    </body>
    </html>
    

    In the code above you just have to mention the city name with their Lat and Long, And rest map will create the line between them for you.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: