react-leaflet-google-places-searchbox
Version:
React-Leaflet plugin for Google Places SearchBox, Support for custom menus
62 lines (58 loc) • 1.59 kB
JavaScript
import {observable, action} from 'mobx';
class leafletStoreClass {
centerLatlng = {
lat: 31.0,
lng: 121.0
};
makerLatlng = this.centerLatlng;
zoom = 6;
maptype = 'ROADMAP';
showMarkerInfo = true;
showMenu = false;
showRoadMap = true;
showTerrain = false;
showSatellite = false;
setMakerPosition(makerPosition) {
this.makerLatlng = makerPosition;
this.centerLatlng = makerPosition;
}
setViewportChange(viewport) {
this.zoom = viewport.zoom;
}
setShowMenu(showMenu) {
this.showMenu = showMenu;
}
setShowMarkerInfo(showMarkerInfo) {
this.showMenu = false;
this.showMarkerInfo = showMarkerInfo;
}
setShowRoadMap(showRoadMap) {
if(showRoadMap){
this.showMenu = false;
this.showSatellite = false;
this.showTerrain = false;
this.showRoadMap = showRoadMap;
this.maptype = 'ROADMAP';
}
}
setShowTerrain(showTerrain) {
if(showTerrain){
this.showMenu = false;
this.showRoadMap=false;
this.showTerrain = showTerrain;
this.showSatellite = false;
this.maptype = 'TERRAIN';
}
}
setShowSatellite(showSatellite) {
if(showSatellite){
this.showMenu = false;
this.showRoadMap=false;
this.showSatellite = showSatellite;
this.showTerrain = false;
this.maptype = 'HYBRID';
}
}
}
const leafletStore = new leafletStoreClass();
export default leafletStore;