14

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.

Pete Kirkham
  • 46,814
  • 5
  • 86
  • 159
Thien Pham
  • 157
  • 1
  • 1
  • 4

8 Answers8

4

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);
Joel Harris
  • 1,837
  • 2
  • 19
  • 32
  • I couldn't get `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'` – a coder Aug 08 '16 at 18:46
  • Using `https://tile.openstreetmap.org/1/1/1.png` returns [security certificate](http://imgur.com/a/JDjyn) errors. – a coder Aug 09 '16 at 15:36
3

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.

Rens
  • 59
  • 4
3

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
Tim Autin
  • 5,663
  • 5
  • 40
  • 65
3

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

2

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

0

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.

Thien Pham
  • 157
  • 1
  • 1
  • 4
0

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

MapQuest Plugin Documentation

Anestis Kivranoglou
  • 6,398
  • 4
  • 38
  • 42
  • Any clues on how best to implement the updated mapquest api with the [LeafletJS users map](http://users.leafletjs.com/)? I tried adding the script in your answer (with my own key), but not having much luck. – a coder Aug 08 '16 at 18:25
  • We just followed their basic map documentation. https://developer.mapquest.com/documentation/leaflet-plugins/maps – Anestis Kivranoglou Aug 09 '16 at 08:27
  • I ended up using a modified version of [another answer](http://stackoverflow.com/questions/38315300/mapquest-direct-tile-access-discontinued/38324489?noredirect=1#comment65038325_38375848). – a coder Aug 09 '16 at 15:33
-3

I switched to ESRI basemap, it works fine.

Make sure you have leaflet referenced:

enter image description here

You can also use world_Street_Map and other ESRI basemaps.

David Makogon
  • 64,809
  • 21
  • 130
  • 175