As of today 2016-07-11, MapQuest has discontinued direct access to their tiles. They seem to only support Leaflet, iOS and Android SDKs. Any idea how to get Openlayers to work with MapQuest again, or should we be thinking of a different alternative? Thanks.
For basemap imagery with OpenLayers, we are basically down to Bing Maps, Mapbox, and DigitalGlobe. All three services require an API key, and all three offer a free tier.
I'm currently using DigitalGlobe and have been very pleased with their resolution and coverage thus far. To use it in OpenLayers, first sign up for an API key at their site.
http://mapsapidocs.digitalglobe.com/
Then just use the following tile source (remember to replace YOUR_ACCESS_TOKEN):
new ol.layer.Tile({
title: 'DigitalGlobe Maps API: Recent Imagery with Streets',
attribution: "© DigitalGlobe, Inc",
source: new ol.source.XYZ({
url: 'http://api.tiles.mapbox.com/v4/digitalglobe.nal0mpda/{z}/{x}/{y}.png?access_token=YOUR_ACCESS_TOKEN'
})
})
This gives you their global satellite imagery with resolutions ranging from a few meters down to 10 centimeters! They offer more base layers than the one I provided in this example, but this should get you started quickly.
For more OpenLayers examples with DigitalGlobe, see this link:
http://mapsapidocs.digitalglobe.com/docs/maps-api-openlayers
It's as simple as changing your tileUrl.
Replace this:
var tileUrl = 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png?x';
with this:
var tileUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
Then use as before:
L.tileLayer(tileUrl, { }).addTo(map);
tileUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
to work. I was able to get this to work if I used tileUrl = 'http://tile.openstreetmap.org/{z}/{x}/{y}.png'
–
Wandie https://tile.openstreetmap.org/1/1/1.png
returns security certificate errors. –
Wandie Use the OSM source:
var osmLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
instead of this:
new ol.layer.Tile({
source: new ol.source.MapQuest({ layer: 'osm' })
});
Works good with OL3.
I asked them on their forum. The answer is no, we can't use MapQuest tiles anymore with any other SDK than those provided by MapQuest.
Also, even with MapQuest SDKs, caching / storing data is forbidden, even with a paid account.
The only other option (that I know) if you need a free, unlimited, worldwide map, is Open Street Map. No satellite imagery though, MapQuest was, sadly, the only one (that I know).
If you are ready to pay, you should be able to use MapBox.
EDIT: another fresh new I just got by e-mail from MapQuest team:
actually we don't do the maps anymore, we use Mapbox.
MapQuest is focusing on some mobile and IoT applications, routing and direction engines rather than maps
For basemap imagery with OpenLayers, we are basically down to Bing Maps, Mapbox, and DigitalGlobe. All three services require an API key, and all three offer a free tier.
I'm currently using DigitalGlobe and have been very pleased with their resolution and coverage thus far. To use it in OpenLayers, first sign up for an API key at their site.
http://mapsapidocs.digitalglobe.com/
Then just use the following tile source (remember to replace YOUR_ACCESS_TOKEN):
new ol.layer.Tile({
title: 'DigitalGlobe Maps API: Recent Imagery with Streets',
attribution: "© DigitalGlobe, Inc",
source: new ol.source.XYZ({
url: 'http://api.tiles.mapbox.com/v4/digitalglobe.nal0mpda/{z}/{x}/{y}.png?access_token=YOUR_ACCESS_TOKEN'
})
})
This gives you their global satellite imagery with resolutions ranging from a few meters down to 10 centimeters! They offer more base layers than the one I provided in this example, but this should get you started quickly.
For more OpenLayers examples with DigitalGlobe, see this link:
http://mapsapidocs.digitalglobe.com/docs/maps-api-openlayers
This problem is happened because.. Direct Access to MapQuest map tiles without a key will end on 11 July 2016. Details on getting keys and SDKs.
for confirmation you can visit following URL
https://lists.openstreetmap.org/pipermail/talk/2016-June/076106.html
At the moment, I temporarily switched to Bings map as a workaround. Yes, it also requires an api key, but at least it is working with OL3.
As this question gained popularity for any interested panicked Leaflet users this is a quick solution.
Instead of creating your map Layers through Leaflet directly now you need to Download And Include (Dont forget your key) the MapQuest Leaflet Plugin.
<script src="https://www.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=KEY"></script>
Then you create your map Layer with the MapQuest Plugin
window.map = L.map('map', {
center: [50.066, 8.73],
zoom: 13
//Or alternatively init layer here layers:MQ.mapLayer()
});
var mapLayer = MQ.mapLayer().addTo(map);
I switched to ESRI basemap, it works fine.
Make sure you have leaflet referenced:
You can also use world_Street_Map and other ESRI basemaps.
© 2022 - 2024 — McMap. All rights reserved.