/
SimpleMapFunctionBase.js
50 lines (49 loc) · 1.44 KB
/
SimpleMapFunctionBase.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
48
49
50
import React, { useState } from "react";
import NeshanMap from "../NeshanMap";
import NeshanMapLoader from "../NeshanMapLoader";
const SimpleMap = () => {
const [ol, setOl] = useState();
return (
<>
<NeshanMapLoader onLoad={setOl}>
{ol && (
<NeshanMap
options={{
key: "YOUR_API_KEY",
maptype: "dreamy",
poi: true,
traffic: false,
view: new ol.View({
center: ol.proj.fromLonLat([51.338076, 35.699756]),
zoom: 14,
}),
}}
onInit={(myMap) => {
var layer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [
new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([51.338076, 35.699756])
),
}),
],
}),
style: new ol.style.Style({
image: new ol.style.Icon({
color: "#BADA55",
crossOrigin: "anonymous",
src:
"https://openlayers.org/en/latest/examples/data/square.svg",
}),
}),
});
myMap.addLayer(layer);
}}
/>
)}
</NeshanMapLoader>
</>
);
};
export default SimpleMap;