google maps direction service with leafletjs

1,693 views
Skip to first unread message

Rana Technobd

unread,
Apr 2, 2014, 4:40:11 AM4/2/14
to leafl...@googlegroups.com
Hi

Is it possible to integrate google maps direction service with leafletjs ? I just did this below

    var map;
    map = new L.Map('map', {center: new L.LatLng(35.6004389, -106.05258409999999), zoom: 4});
    var googleLayer = new L.Google('ROADMAP');
    map.addLayer(googleLayer);
    var LeafIcon = L.Icon.extend({
      options: {
        iconAnchor:   [21, 56],
        popupAnchor:  [0, -41]
      }
    });
    var marker1 = L.marker([35.6004389, -106.05258409999999], {icon: greenIcon});
    marker1.bindPopup("I am a green leaf.").addTo(map);
    L.marker([38.6114824, -121.44280249999997], {icon: new LeafIcon({iconUrl: 'http://technobd.rvillage.com/application/modules/Rvillage/externals/images/friends_multiple.png'})}).bindPopup("I am a friends_multiple leaf.").addTo(map);

added popups & markers, here is the jsfiddle can anyone give me any idea how to integrate google maps routing with leafletjs

thanks

Vladimir Agafonkin

unread,
Apr 4, 2014, 8:04:55 AM4/4/14
to leafl...@googlegroups.com
Unfortunately it is forbidden by the Google Maps API Terms of Use. You can't display Google Directions results on anything other than a GMaps API v3 map.

Arnie Shore

unread,
Apr 4, 2014, 8:24:50 AM4/4/14
to leafl...@googlegroups.com


--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bernd Loigge

unread,
Apr 4, 2014, 11:26:15 AM4/4/14
to leafl...@googlegroups.com
Hi,

I am also looking to use the mapquest routing plugin. 

I have already integrated mapquest and it works fine with some random coordinates:

dir.route({
    locations: [
'48.216,16.384',
'48.218,16.377',
'48.218,16.385',
'48.224,16.387',
'48.226,16.386',
]
});

I am now looking for a solution to get the directions between the markers I loaded. I am using joker-x's Leaflet.geoCSV.

Is there a way to get the lat and lng from the csv in an array so that I can get the directions between all the data I loaded into my map?


thanks

Bernd Loigge

unread,
Apr 4, 2014, 11:38:05 AM4/4/14
to leafl...@googlegroups.com
I just started using Javascript but I guess I have to integrate something in this part of my code where I loop through all the csv data:

var points = L.geoCsv(null, {
fieldSeparator: '\t',
onEachFeature: function (feature, layer) {
var popup = '';
for (var clave in feature.properties) {
var title = points.getPropertyTitle(clave);
popup += '<b>'+title+'</b><br />'+feature.properties[clave]+'<br /><br />';
}
layer.bindPopup(popup).bindLabel(feature.properties[points.getPropertyName('SiteID')], {noHide: true});
},
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
icon:myicon
});
},
firstLineTitles: true
});
Reply all
Reply to author
Forward
0 new messages