Not unlike others, I've found myself forced to edit some code due to MapQuest changing how they offer the openstreetmap data, and using an API Key.
Getting the key, aswell as getting up a simple leaflet map zoomed to where i wanted went easily.
Now I'm trying to add a layer of points of interest, based on a text file. I had/have the data in a file 'textfile.txt', and through OpenLayers I was able to display the markers using the following code snippet:
var pois = new OpenLayers.Layer.Text( "Archieflijst",
{ location:"./textfile.txt",
projection: map.displayProjection
});
map.addLayer(pois);
How would I make that work now?
For reference, i'll post current code-build, without my actual API-key:
<html>
<head>
<title>Werkterrein</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.5/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.5/leaflet.js"></script>
<script src="https://www.mapquestapi.com/sdk/leaflet/v2.s/mq-map.js?key=key_goes_here"></script>
<script src="ol.js"></script>
<script type="text/javascript">
window.onload = function() {
var mapLayer = MQ.mapLayer(), map;
map = L.map('map', {
layers: mapLayer,
center: [50.94517,3.11969],
zoom: 11
});
L.control.layers({
'Map': mapLayer,
'Hybrid': MQ.hybridLayer(),
'Satellite': MQ.satelliteLayer(),
'Dark': MQ.darkLayer(),
'Light': MQ.lightLayer()
}).addTo(map);
var pois = new ol.Layer.Text( "Archieflijst",
{ location:"./textfile.txt",
projection: map.displayProjection
});
map.addLayer(pois);
}
</script>
</head>
<body style='border:0; margin: 0'>
<div id='map' style='width:1100px; height:530px;'></div>
</body>
</html>
I have 'textfile.txt' and 'ol.js' in the same folder.
Contents + example line for textfile.txt:
lat lon title description icon iconSize iconOffset
51.0049363376102 3.19743523027068 Elk logo vertegenwoordigt een gerealiseerd project icoon.png 16,16 -8,-8
OpenLayers.Layer.Text
, but it can easily be built. Can you post a couple of lines of the data in your textfile.txt, so that we can help you out with that.