Fix map using OpenLayers 4.3.3

This commit is contained in:
Vidir Valberg Gudmundsson 2017-09-25 00:54:47 +02:00
parent e938723986
commit f791f00b55

View file

@ -129,26 +129,44 @@
var lat = 55.6886382;
var lon = 12.5618443;
var zoom = 18;
var position = ol.proj.fromLonLat([lon, lat]);
var positionFeature = new ol.Feature({
type: 'geoMarker',
geometry: new ol.geom.Point(position)
});
var fromProjection = new ol.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new ol.Projection("EPSG:900913"); // to Spherical Mercator Projection
var position = new ol.LonLat(lon, lat).transform( fromProjection, toProjection);
map = new ol.Map("Map");
var mapnik = new ol.Layer.OSM();
map.addLayer(mapnik);
var markers = new ol.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new ol.Marker(position));
map.setCenter(position, zoom);
var map = new ol.Map({
target: 'Map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Vector({
source: new ol.source.Vector({
features: [positionFeature]
}),
style: new ol.style.Style({
image: new ol.style.Circle({
fill: new ol.style.Fill({
color: 'rgba(255,0,0,0.8)'
}),
radius: 10
})
})
})
],
view: new ol.View({
center: position,
zoom: zoom
}),
interactions: [], // No dragging or other funny biz
});
</script>
<p>
<address>
<strong>{{ site.data.strings[section_where_address] }}</strong><br />
<a href="https://www.ms.dk/mellemrummet">Mellemrummet</a><br />
<a href="https://www.ms.dk/mellemrummet">Cafe Mellemrummet</a><br />
Ravnsborggade 11<br />
2200 København Nørrebro
</address>
@ -184,6 +202,5 @@
</div>
</footer>
<script src="js/bootstrap.min.js"></script>
</body>
</html>