2013-06-03 43 views
-1

我正在考慮將我的應用程序從小冊子切換到OpenMapquest。使用openMapQuest與流星框架

主要的原因是我需要OpenMapquest的免費路由能力,

的問題是,小葉具有一包流星,但OpenMapQuest沒有。是否有可能開關?僅包含OpenMapQuest的js文件就足夠了嗎?或者是否有免費的選擇來繪製Leaflet的路線?

謝謝

回答

1

編輯
下面的代碼只改變了瓷磚,不會影響路由。請參閱MapQuest directions web service關於如何使用JavaScript從其路由服務獲取路由數據。


根據this博客文章,你只需要改變序言。

的Cloudmade映射層看起來是這樣的:

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}); 

更改序言。

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/

+0

這隻會改變地圖的外觀,它不允許我使用mapquest的路由服務對嗎? –

+0

是的你是對的。 – Fallexe

0

聲明:我在MapQuest的工作。

我還沒有嘗試過這個,但是您可以向Open Directions API發出請求(通過您的基於Leaflet的應用程序),請求提供mapState,然後解析結果並顯示routeShape你的地圖。請記住,我自己並沒有嘗試過,因此我不確定它是否可行,但它可能是您的一個選擇。

+0

我想過了,你說得對,路由webservice發回這些信息,但它們只能在MapQuest中使用,這是合乎邏輯的。 無論如何,我設法使用沒有問題的流星使用Mapquest。所以謝謝你的出色工作:) –