How to draw a line between two point in Google map?

mySun

I need draw a curved line between two point in Google map.

How to draw with jQuery?

This code is for One point. How to change for 2 point and draw a curved line between two point in Google map?

My code is:

if ($('#map-canvas-airport').length) {
var map,
    service;

jQuery(function($) {
    $(document).ready(function() {
        var lat = $('#airport-map').data('google-lat');
        var lng = $('#airport-map').data('google-lng');
        var latlng = new google.maps.LatLng(lat, lng);
        var myOptions = {
            zoom: 13,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scrollwheel: false
        };

        map = new google.maps.Map(document.getElementById("map-canvas-airport"), myOptions);


        var marker = new google.maps.Marker({
            position: latlng,
            map: map
        });
        marker.setMap(map);


        $('a[href="#google-map-tab"]').on('shown.bs.tab', function(e) {
            google.maps.event.trigger(map, 'resize');
            map.setCenter(latlng);
        });
    });
});
}

In HTML:

<div class="tab-pane fade" id="airport-map" data-google-lat="{{ $iata -> lat }}" data-google-lng="{{ $iata -> lng }}">
   <div id="map-canvas-airport" style="width:100%; height:500px;"></div>
</div>
TedMeftah

From the google docs:

var map = new google.maps.Map(...); // init the map
var lineCoordinates = [
  {lat: 1, lng: 1},
  {lat: 2, lng: 2},
  {lat: 3, lng: 3},
  {lat: 4, lng: 4}
];
var linePath = new google.maps.Polyline({
  path: lineCoordinates,
  geodesic: true,
  strokeColor: '#FF0000'
});

linePath.setMap(map);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I draw a line between two google map native markers? (Ionic 3, cordova)

how to draw a line with two point in it in flutter

Multiple polyline between two point in google map

GoogleMaps : How to draw dash line to connect with starting point of direction path on google map ios

How to draw polyline on google map with two different colors between two locations

How to draw a line / link between two points on a D3 map based on latitude / longitude?

How to draw line between the markers in google map, using laravel5.2

How can I draw polyline Between two location in Google Map using Android?

How to draw line between two points in JavaScript - Google Maps Api Route

How to draw a line between a data point and an axis in matplotlib?

How draw line between point using achart engine android

How to draw vertical separation line between two text line android?

Get distance and draw line between two location android google maps

How To Draw Path On Google Map Based on array of Point in Json String

How to project two point line on the map into a curved line OpenLayers

Get Distance Between Specific Point to the Line Drawn on Google Map

How to draw image dynamically on a canvas line between two cells

How do I draw an Ideal line between two headers?

Matplotlib how to draw vertical line between two Y points

How to draw line between two circle in html canvas element

How do I draw a horizontal line between two circles with CSS?

How to draw a line between two points over an image in swift 3?

How to draw a line between two views in Swift 3?

How to draw a line between two given points in R with plotly?

How to draw a line between two points objective-C

How to re-draw line connected between moveable two UIView

How to draw a line between two points with js and CSS

draw straight line between any two point when using coord_polar() in ggplot2 (R)

Draw arrow between on line between two points

TOP Ranking

HotTag

Archive