-
Notifications
You must be signed in to change notification settings - Fork 3
/
map.js
47 lines (42 loc) · 1.09 KB
/
map.js
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
41
42
43
44
45
46
47
var baseMapLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var map = new ol.Map({
target: 'map',
layers: [ baseMapLayer],
view: new ol.View({
center: ol.proj.fromLonLat([-74.0061,40.712]),
zoom: 12 //Initial Zoom Level
})
});
var marker = new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([-74.006,40.7127])
), // Cordinates of New York's City Hall
});
marker.setStyle(new ol.style.Style({
image: new ol.style.Icon( ({
color: '#ffcd46',
crossOrigin: 'anonymous',
src: 'dot.png'
}))
}));
var vectorSource = new ol.source.Vector({
features: [marker]
});
var markerVectorLayer = new ol.layer.Vector({
source: vectorSource,
});
map.addLayer(markerVectorLayer);
var north = 40.7127;
var south = 40.7129;
var east = -74.0059;
var west = -74.0061;
var extent = ol.proj.transformExtent([east, north, west, south], 'EPSG:4326', 'EPSG:3857');
var imageLayer = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: 'photo.png',
imageExtent: extent
})
});
map.addLayer(imageLayer);