-
Notifications
You must be signed in to change notification settings - Fork 1
/
WrldMap.js
49 lines (38 loc) · 1.47 KB
/
WrldMap.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
import EventEmitter from "~/shared/EventEmitter";
export default class WrldMap {
constructor(reactNativeMapController) {
this._mapViewData = {};
this._reactNativeMapController = reactNativeMapController;
this._internalEventEmitter = new EventEmitter;
}
_registerEvents() {
this._reactNativeMapController.registerEvent("initialstreamingcomplete", ({ data }) => { this._onMapViewUpdate(data); });
this._reactNativeMapController.registerEvent("mapviewupdate", ({ data }) => { this._onMapViewUpdate(data); });
}
_onMapViewUpdate(mapViewData) {
this._mapViewData = mapViewData;
this._internalEventEmitter._emit("internal_mapviewupdate", mapViewData);
}
init(latLng) {
this._reactNativeMapController.init(latLng);
this._registerEvents();
}
registerMapViewUpdateEvent(callback) {
this._internalEventEmitter.on("internal_mapviewupdate", callback);
}
unregisterMapViewUpdateEvent(callback) {
this._internalEventEmitter.off("internal_mapviewupdate", callback);
}
registerEvent(type, callback) {
this._reactNativeMapController.registerEvent(type, callback);
}
unregisterEvent(type, callback) {
this._reactNativeMapController.unregisterEvent(type, callback);
}
setView(latLng) {
this._reactNativeMapController.sendMessage("map_setView", { center: latLng })
}
getMapView() {
return this._mapViewData;
}
}