-1

I'm thinking of switching my Application from leaflet to OpenMapquest.

The main reason is that i need the free routing capability of OpenMapquest,

The problem is that leaflet has a package for meteor, but OpenMapQuest has not. Is it possible to make the switch ? is it enough to just include the js files of OpenMapQuest ? Or is there a free alternative to draw routes of Leaflet ?

Thank you

qJake
  • 16,821
  • 17
  • 83
  • 135
Dany Y
  • 6,833
  • 6
  • 46
  • 83

2 Answers2

1

EDIT
The code below only changes the tiles and does not impact routing. See MapQuest directions web service on how to use JavaScript to get routing data from their Route Service.


According to this blog post, you just need to change the preamble.

The Cloudmade maps layer looks like this.:

var map = new L.Map('map');
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/API-KEY/997/256/{z}/{x}/{y}.png',
cloudmadeAttrib = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttrib});

Change the preamble to.

var map = new L.Map('map');
var mapquestUrl = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
    subDomains = ['otile1','otile2','otile3','otile4'],
    mapquestAttrib = 'Data, imagery and map information provided by <a href="http://open.mapquest.co.uk" target="_blank">MapQuest</a>, <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors.',
    mapquest = new L.TileLayer(mapquestUrl, {maxZoom: 18, attribution: mapquestAttrib, subdomains: subDomains});

http://sajjad.in/2012/01/mapquest-tiles-through-leaflet-js/

Fallexe
  • 596
  • 2
  • 11
  • This will just change the looks of the map, it doesn't allow me to use the routing services of mapquest right? – Dany Y Jun 04 '13 at 14:40
0

Disclaimer: I work at MapQuest.

I haven't tried this myself, but you might be able to make a request to the Open Directions API (from your Leaflet-based app), provide a mapState with your request, and then parse the results and display the routeShape on your map. Keep in mind I haven't tried this myself so I don't know for sure if it would work, but it may be an option for you.

jharahush
  • 767
  • 4
  • 6
  • I thought about it, and you're right the routing webservice sends back these info, but they're only usable in MapQuest, which is logical. Anyway, I managed to use Mapquest with meteor without a problem. So thank you for your great work :) – Dany Y Jun 12 '13 at 22:36