-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathol-map-marker.js
More file actions
40 lines (38 loc) · 860 Bytes
/
ol-map-marker.js
File metadata and controls
40 lines (38 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Create Icon
*/
var lon = 21.002902;
var lat = 52.228850;
var MarkerIcon = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([lon,lat])),
name: 'Marker text',
desc: '<label>Details</label> <br> Latitude: ' + lat + ' Longitude: ' + lon
})
// Add icon style
MarkerIcon.setStyle(new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 50],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
src: 'img/marker-64.png'
// ,scale: 0.4
})
}));
/*
Create map source
*/
var MapSource = new ol.source.Vector({
features: [
MarkerIcon
]
})
// Create map layer
var MapLayer = new ol.layer.Vector({
source: MapSource
});
// Set layer z-index
MapLayer.setZIndex(999);
// Add marker to layer
map.addLayer(MapLayer);
// Clear markers from source
// MapSource.clear();