Преглед на файлове

fix 数据库mapdata查询、父子组件传值、publish发布传值等方法修改

Jay преди 6 дни
родител
ревизия
2e23ee0ee3
променени са 7 файла, в които са добавени 96 реда и са изтрити 298 реда
  1. 0 3
      craco.config.js
  2. 2 1
      src/ctrl/VectorDataManager.js
  3. 5 2
      src/index.js
  4. 8 15
      src/model/AccountAuth.js
  5. 12 166
      src/view/App.js
  6. 22 48
      src/view/Body.js
  7. 47 63
      src/view/Map.js

+ 0 - 3
craco.config.js

@@ -2,8 +2,6 @@ const path = require('path');
 const { name } = require('./package.json')
 
 module.exports = {
-  // 
-
   // // 暴露的全局名字
   // name: 'MySdk',
   // // 输出的各种包文件
@@ -23,7 +21,6 @@ module.exports = {
         library: 'ThreeX',
         libraryTarget: 'umd',
         umdNamedDefine: true
-
       }
     }
     // configure: (webpackConfig, { env, paths }) => {

+ 2 - 1
src/ctrl/VectorDataManager.js

@@ -1259,7 +1259,8 @@ class VectorDataManager extends HistorizedManager {
 
 			try {
 				changesetId = await this._osmApi.createChangeset(
-					window.EDITOR_NAME + ' ' + PACKAGE.version,
+					// window.EDITOR_NAME + ' ' + PACKAGE.version,
+					PACKAGE.name + ' ' + PACKAGE.version,
 					tags.comment || "Edited building indoors",
 					mytags
 				);

+ 5 - 2
src/index.js

@@ -57,9 +57,12 @@ console.log(window.CONFIG)
 window.EDITOR_NAME = window.CONFIG.editor_name;
 
 // Create app
-// new App({ el: 'root', id: 'swa3s5ex', url:"ws://121.42.8.157:19702" }).init();
-new App({ el: 'root' }).init();
+let app = new App({ el: 'root', id: 'swa3s5ex', url:"ws://121.42.8.157:19702" })
+// new App({ el: 'root' }).init();
+console.log(app)
+app.init();
 
+console.log(app.child.current)
 
 // const BunnyBlitz = {
 // 	MAP: App,

+ 8 - 15
src/model/AccountAuth.js

@@ -5,7 +5,9 @@ import PubSub from 'pubsub-js';
 // const [fooEvents, setFooEvents] = useState([]);
 
 class AccountAuth {
-    constructor(url){
+    constructor(url, id){
+        this.url = url;
+        this.mapUUID = id
         // const URL = '121.42.8.157:19702'
         // this._socket = io(URL, {
         this._socket = io(url, {
@@ -35,7 +37,7 @@ class AccountAuth {
                     FROM 
                         medba.dat_map 
                     WHERE 
-                        map_uuid = '${window.mapUUID}'`;
+                        map_uuid = '${this.mapUUID}'`;
             var msg = {
                 cmd: "query", // server端要进行判断的
                 data: {
@@ -43,19 +45,10 @@ class AccountAuth {
                     sql: sql,
                 },
             };
-            this._socket.emit("REPT", msg, (datas) => {
-                // console.log(datas.data);
-                const result = datas.data;
-                window.editor_user = {
-					maps: []
-				};
-                for (let i = 0; i < result.length; i++) {
-                    const map = result[i];
-                    // console.log(map);
-                    window.editor_user.maps.push(map);
-                }
-
-                PubSub.publish('body.map.got');
+            this._socket.emit("REPT", msg, (res) => {
+                console.log(res.data);
+                
+                PubSub.publish('body.map.got', res.data);
             });  
         }, 1000);
     }

+ 12 - 166
src/view/App.js

@@ -22,9 +22,10 @@ export default class App {
 		this.el = params.el
 		this.id = params.id
 		this.url = params.url
-		if(params.origin){
+
+		if (params.origin) {
 			this.origin = new LatLng(params.origin[0], params.origin[1])
-		}else{
+		} else {
 			this.origin = new LatLng(0, 0)
 		}
 
@@ -35,12 +36,14 @@ export default class App {
 			enumerable: false,
 			configurable: false
 		});
+
+		this.child = React.createRef();
 	}
 
 	init() {
 		this._initCtrl();
 		this._initView();
-		this._initAuth();
+		this._initIndoorMap();
 	}
 
 
@@ -63,8 +66,8 @@ export default class App {
 	 * @private
 	 */
 	_initView() {
-		ReactDOM.render(<Body uuid={this.id} center={this.center}/>, document.getElementById(this.el));
-		document.title = window.EDITOR_NAME;
+		ReactDOM.render(<Body center={this.center} ref={this.child} />, document.getElementById(this.el));
+		// document.title = window.EDITOR_NAME;
 
 		// Disabling context menu
 		document.oncontextmenu = () => {
@@ -76,7 +79,10 @@ export default class App {
 	 * Launches authentication process
 	 * @private
 	 */
-	_initAuth() {
+	_initIndoorMap() {
+
+		window.editor_user_auth = new AccountAuth(this.url, this.id);
+
 		// const opts = {
 		// 	apiUrl: window.CONFIG.osm_api_url,
 		// 	url: window.CONFIG.osm_api_url,
@@ -92,7 +98,6 @@ export default class App {
 
 		// if(params.code) {
 		// 	window.editor_user_auth.authenticate(() => {
-		// 		this._checkAuth();
 		// 		localStorage.setItem("oauth_token", params.code);
 		// 		window.history.replaceState({}, "", window.location.href.replace(/\?.*/, ""));
 		// 	});
@@ -108,167 +113,8 @@ export default class App {
 		// 	this.authWait = setInterval(this._checkAuth.bind(this), 100);
 		// }
 
-		window.editor_user_auth = new AccountAuth(this.url);
-
-		/**
-		 * Event for logging in user
-		 * @event app.user.login
-		 * @memberof App
-		 */
-		PubSub.subscribe("app.user.login", (msg, data) => {
-			// if(!window.editor_user_auth.authenticated()) {
-			// 	window.editor_user_auth.authenticate((err, res) => {
-			// 		if(err) {
-			// 			console.error(err);
-			// 			alert(I18n.t("Oops ! Something went wrong when trying to log you in"));
-			// 			PubSub.publish("app.user.logout");
-			// 		}
-			// 		else {
-			// 			this._checkAuth();
-			// 		}
-			// 	});
-			// }
-			console.log("index ", data);
-			if (!window.editor_user_auth.authenticated()) {
-				window.editor_user_auth.authenticate(data, (err, res) => {
-					console.log('index ok');
-					if (err) {
-						console.error(err);
-						alert("哎呀!尝试登录时出错。");
-						PubSub.publish("app.user.logout");
-					}
-					else {
-						console.log('enter _checkAuth');
-						this._checkAuth(res);
-					}
-				});
-			}
-
-		});
-
-		/**
-		 * Event for logging out user (not done yet)
-		 * @event app.user.logout
-		 * @memberof App
-		 */
-		PubSub.subscribe("app.user.logout", (msg, data) => {
-			if (window.editor_user_auth && window.editor_user_auth.authenticated()) {
-				window.editor_user_auth.logout();
-			}
-
-			window.editor_user = null;
-			localStorage.removeItem("oauth_token");
-
-			/**
-			 * Event when user has been successfully logged out
-			 * @event app.user.left
-			 * @memberof App
-			 */
-			PubSub.publish("app.user.left");
-		});
-
-		PubSub.subscribe('body.data.save', (msg, data) => {
-			window.editor_user_auth.updateMapData({
-				map_data: data,
-				user_id: window.editor_user.id,
-				map_id: window.editor_user.edit_map,
-			});
-		});
-
-		PubSub.subscribe('editor.map.create', (msg, data) => {
-			window.editor_user_auth.cteateMapData(data.id, data.name);
-		});
-
-		PubSub.subscribe('editor.map.rename', (msg, data) => {
-			window.editor_user_auth.updateMapName(data.id, data.name);
-		});
-
-		PubSub.subscribe('editor.map.edit', (msg, data) => {
-			// window.editor_user_auth.cteateMapData(data.id, data.name);
-			const map = window.editor_user.maps.filter(m => m.map_id === data.id)[0];
-			window.editor_user.edit_map = data.id;
-			PubSub.publish('body.map.change', map);
-		});
-
-		PubSub.subscribe('editor.map.delete', (msg, data) => {
-			window.editor_user_auth.deleteMapData(data.id);
-		});
 	}
 
-	/**
-	 * Check if authentication happened
-	 * @private
-	 */
-	_checkAuth(res) {
-		if (window.editor_user_auth.authenticated()) {
-			if (this.authWait) {
-				clearInterval(this.authWait);
-			}
-
-			try {
-				window.editor_user = {
-					id: res.user_id,
-					account: res.user_account,
-					token: res.user_token,
-					name: res.user_name,
-					auth: window.editor_user_auth,
-					edit_map: 0,
-					maps: []
-				};
-
-				// console.log('_checkAuth', window.editor_user);
-
-				//登录完成后查询是否有地图数据,如没有则创建一个
-				window.editor_user_auth.hasMapData(res.user_id);
-
-				/**
-				 * Event when user has been successfully logged in
-				 * @event app.user.ready
-				 * @memberof App
-				 */
-				PubSub.publish("app.user.ready", { username: window.editor_user.name });
-				console.log("Logged in as", window.editor_user.name);
-
-				localStorage.setItem("editor_token", res.user_token);
-			}
-			catch (e) {
-				console.error(e);
-				PubSub.publish("app.user.logout");
-			}
-
-			//Get user details
-			// window.editor_user_auth.xhr({
-			// 	method: 'GET',
-			// 	path: '/api/0.6/user/details'
-			// }, (err, details) => {
-			// 	if(err) {
-			// 		console.log(err);
-			// 		window.editor_user_auth.logout();
-			// 	}
-			// 	else {
-			// 		try {
-			// 			window.editor_user = {
-			// 				id: details.firstChild.childNodes[1].attributes.id.value,
-			// 				name: details.firstChild.childNodes[1].attributes.display_name.value,
-			// 				auth: window.editor_user_auth
-			// 			};
-
-			// 			/**
-			// 			 * Event when user has been successfully logged in
-			// 			 * @event app.user.ready
-			// 			 * @memberof App
-			// 			 */
-			// 			PubSub.publish("app.user.ready", { username: window.editor_user.name });
-			// 			console.log("Logged in as", window.editor_user.name);
-			// 		}
-			// 		catch(e) {
-			// 			console.error(e);
-			// 			PubSub.publish("app.user.logout");
-			// 		}
-			// 	}
-			// });
-		}
-	}
 
 	/**
 	 * Parse URL parameters

+ 22 - 48
src/view/Body.js

@@ -128,7 +128,6 @@ class Body extends Component {
 			<Map
 				ref={elem => this.map = elem}
 				{...this.state}
-				uuid={this.props.uuid}
 			/>
 		</Container>;
 	}
@@ -230,27 +229,6 @@ class Body extends Component {
 			});
 	}
 
-	// _refreshMarkers(data){
-	// 	let removeMarkers = [];
-	// 	//判断时间,10秒未更新移除
-	// 	this.markers.forEach(marker => {
-	// 		if(){
-	// 			removeMarkers
-	// 		}
-	// 	});
-	// 	this.markers.filter()
-	// 	if(){
-
-	// 	}
-	// }
-
-	// {"cmd":"tof_data", "version":"1.0.0.0", "data":[["1002",1.1,2.2,1001,3.1,1.1,1,"2022-06-13 16:50:00.023"]]}
-
-	// _updateData(data){
-	// 	console.log('body', data);
-	// 	PubSub.publish('body.data.update', data)
-	// }
-
 	/**
 	 * Append last used preset into stack
 	 * @private
@@ -288,21 +266,21 @@ class Body extends Component {
 	 * Capture imagery used when user perform an action
 	 * @private
 	 */
-	// _addUsedImagery() {
-	// 	// Base imagery
-	// 	if (this.state.selectedBaseImagery && this.state.selectedBaseImagery.properties) {
-	// 		this._usedImageryNames.add(this.state.selectedBaseImagery.properties.name || this.state.selectedBaseImagery.properties.id);
-	// 	}
+	_addUsedImagery() {
+		// Base imagery
+		if (this.state.selectedBaseImagery && this.state.selectedBaseImagery.properties) {
+			this._usedImageryNames.add(this.state.selectedBaseImagery.properties.name || this.state.selectedBaseImagery.properties.id);
+		}
 
-	// 	// Overlays
-	// 	if (this.state.selectedOverlaysImagery && this.state.selectedOverlaysImagery.length > 0) {
-	// 		this.state.selectedOverlaysImagery.forEach(ovl => {
-	// 			if (ovl.properties) {
-	// 				this._usedImageryNames.add(ovl.properties.name || ovl.properties.id);
-	// 			}
-	// 		});
-	// 	}
-	// }
+		// Overlays
+		if (this.state.selectedOverlaysImagery && this.state.selectedOverlaysImagery.length > 0) {
+			this.state.selectedOverlaysImagery.forEach(ovl => {
+				if (ovl.properties) {
+					this._usedImageryNames.add(ovl.properties.name || ovl.properties.id);
+				}
+			});
+		}
+	}
 
 	componentDidMount() {
 		this._timerImagery = setInterval(() => this._updateImagery(), 1000);
@@ -474,17 +452,13 @@ class Body extends Component {
 		// });
 
 		PubSub.subscribe("body.map.got", (msg, data) => {
-			// window.editor_user.maps.max
 			// this.setState({mapDashboardOpen: true});
-			const maps = window.editor_user.maps;
-			if (maps.length > 0) {
-				let map = maps[0];
-				// console.log("map有", maps.length, "个 选择了", map.map_id);
-				window.editor_user.edit_map = map.map_id;
-				PubSub.publish('body.draw.loaded', JSON.parse(map.map_data));
+			// console.log(123, msg, data)
+			if (data.length > 0) {
+				// console.log(data[0].map_id);
+				PubSub.publish('body.draw.loaded', JSON.parse(data[0].map_data));
 			} else {
 				console.log("body.map.got none");
-				// window.editor_user_auth.cteateMapData(window.editor_user.id);
 			}
 		});
 
@@ -1415,10 +1389,10 @@ class Body extends Component {
 		// });
 
 		/**
- * Event for cleaning up all data after changeset upload
- * @event Map zoom changes
- * @memberof Body
- */
+		 * Event for cleaning up all data after changeset upload
+		 * @event Map zoom changes
+		 * @memberof Body
+		 */
 		PubSub.subscribe("map.zoom.changed", (msg, data) => {
 			this.setState({ zoom: data.zoom });
 

+ 47 - 63
src/view/Map.js

@@ -37,16 +37,16 @@ const MAP_MIN_ZOOM = 8;
  * Extend leaflet hash for handling level value
  */
 
-L.Hash.parseHash = function(hash) {
-	if(hash.indexOf('#') === 0) {
+L.Hash.parseHash = function (hash) {
+	if (hash.indexOf('#') === 0) {
 		hash = hash.substr(1);
 	}
 	var args = hash.split("/");
 	if (args.length >= 3 && args.length <= 4) {
 		var zoom = parseInt(args[0], 10),
-		lat = parseFloat(args[1]),
-		lon = parseFloat(args[2]),
-		level = args.length === 4 ? parseInt(args[3], 10) : 0;
+			lat = parseFloat(args[1]),
+			lon = parseFloat(args[2]),
+			level = args.length === 4 ? parseInt(args[3], 10) : 0;
 
 		if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
 			return false;
@@ -63,7 +63,7 @@ L.Hash.parseHash = function(hash) {
 };
 L.Hash.prototype.parseHash = L.Hash.parseHash;
 
-L.Hash.formatHash = function(map) {
+L.Hash.formatHash = function (map) {
 	var center = map.getCenter(),
 		zoom = map.getZoom(),
 		precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
@@ -76,8 +76,8 @@ L.Hash.formatHash = function(map) {
 };
 L.Hash.prototype.formatHash = L.Hash.formatHash;
 
-L.Hash.prototype.setLevel = function(lvl) {
-	if(this._level !== lvl) {
+L.Hash.prototype.setLevel = function (lvl) {
+	if (this._level !== lvl) {
 		this._level = lvl;
 		var hash = this.formatHash(this.map);
 		window.location.replace(hash);
@@ -85,7 +85,7 @@ L.Hash.prototype.setLevel = function(lvl) {
 	}
 };
 
-L.Hash.prototype.update = function() {
+L.Hash.prototype.update = function () {
 	var hash = window.location.hash;
 	if (hash === this.lastHash) {
 		return;
@@ -123,8 +123,9 @@ class MyMap extends Component {
 	 * Alert this component that its size has changed
 	 */
 	invalidateSize() {
-		if(this.elem && this.elem.leafletElement) {
+		if (this.elem && this.elem.leafletElement) {
 			this.elem.leafletElement.invalidateSize();
+			this.map = this.elem.leafletElement;
 		}
 	}
 
@@ -165,23 +166,23 @@ class MyMap extends Component {
 	 * @private
 	 */
 	async _loadData(bounds) {
-		if(this.props.datalocked || (window.CONFIG.always_authenticated && !window.editor_user)) {
+		if (this.props.datalocked || (window.CONFIG.always_authenticated && !window.editor_user)) {
 			return new Promise(resolve => {
 				setTimeout(() => resolve(this._loadData(bounds)), 100);
 			});
 		}
-		else if(!this.props.draw && this.getBounds() && this.elem.leafletElement.getZoom() >= window.CONFIG.data_min_zoom) {
+		else if (!this.props.draw && this.getBounds() && this.elem.leafletElement.getZoom() >= window.CONFIG.data_min_zoom) {
 			let bbox = bounds || this.getBounds();
 
 			// Only load data if bbox is valid and not in an already downloaded area
-			if(
+			if (
 				bbox
 				&& bbox.getSouth() !== bbox.getNorth()
 				&& bbox.getWest() !== bbox.getEast()
 				&& (!this.loadedArea || !this.loadedArea.contains(bbox))
 			) {
 				// Augment bbox size if too small (to avoid many data reloads)
-				while(bbox.getSouthWest().distanceTo(bbox.getNorthEast()) < 400) {
+				while (bbox.getSouthWest().distanceTo(bbox.getNorthEast()) < 400) {
 					bbox = bbox.pad(0.1);
 				}
 
@@ -193,7 +194,7 @@ class MyMap extends Component {
 							const result = await window.vectorDataManager.loadOSMData(bbox);
 							this.setState({ loading: false, dataready: result });
 						}
-						catch(e) {
+						catch (e) {
 							alert("Can't download data from OSM server. Please retry later.");
 							this.setState({ loading: false, dataready: false });
 						}
@@ -218,7 +219,7 @@ class MyMap extends Component {
 		// 	// 	.replace(/\{switch:.+?\}/g, "{s}")
 		// 	// 	.replace(/\{-y\}/g, "{y}");
 		// 	const url = "https://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}";
-			
+
 		// 	return <TileLayer
 		// 		attribution="&copy 高德地图"
 		// 		url={url}
@@ -269,7 +270,7 @@ class MyMap extends Component {
 		// 	// 	maxZoom={MAP_MAX_ZOOM}
 		// 	// />;
 		// 	const url = "https://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}";
-			
+
 		// 	return <TileLayer
 		// 		attribution="&copy 高德地图"
 		// 		url={url}
@@ -286,14 +287,14 @@ class MyMap extends Component {
 		// 	return null;
 		// }
 		const url = "https://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}";
-			
+
 		return <TileLayer
 			attribution="&copy 高德地图"
 			url={url}
 			// key={url}
 			minZoom={MAP_MIN_ZOOM}	//{l.properties.min_zoom}
-			maxNativeZoom={18}	//{l.properties.max_zoom}
 			maxZoom={MAP_MAX_ZOOM}
+			maxNativeZoom={18}	//{l.properties.max_zoom}
 			opacity={opacity}
 			tms={l.properties.url.indexOf("{-y}") > 0}
 			key='amap'
@@ -305,7 +306,7 @@ class MyMap extends Component {
 	 * @private
 	 */
 	_getFloorMapLayer(floormap) {
-		if(!floormap || !floormap.topleft) {
+		if (!floormap || !floormap.topleft) {
 			return null;
 		}
 		else {
@@ -313,7 +314,7 @@ class MyMap extends Component {
 				data={floormap}
 				key={floormap.id}
 				opacity={floormap.opacity !== undefined && !isNaN(parseFloat(floormap.opacity)) ? floormap.opacity : 1}
-				ref={"floormap_"+floormap.id}
+				ref={"floormap_" + floormap.id}
 				level={this.props.level}
 				mode={this.props.mode}
 				tool={this.props.floorImageryMode}
@@ -325,11 +326,11 @@ class MyMap extends Component {
 		const floorImgs = window.imageryManager.getFloorImages();
 		let levelsList = null;
 
-		if(this.props.mode === Body.MODE_EXPLORE) {
+		if (this.props.mode === Body.MODE_EXPLORE) {
 			levelsList = window.vectorDataManager.getAllLevels(true);
 		}
-		else if(this.props.mode === Body.MODE_BUILDING) {
-			if(this.props.building) {
+		else if (this.props.mode === Body.MODE_BUILDING) {
+			if (this.props.building) {
 				levelsList = this.props.building.properties.own.levels.slice(0);
 				levelsList.sort();
 			}
@@ -337,7 +338,7 @@ class MyMap extends Component {
 				levelsList = window.vectorDataManager.getAllLevels(false);
 			}
 		}
-		else if([ Body.MODE_LEVELS, Body.MODE_FEATURES ].includes(this.props.mode) && this.props.building) {
+		else if ([Body.MODE_LEVELS, Body.MODE_FEATURES].includes(this.props.mode) && this.props.building) {
 			levelsList = this.props.building.properties.own.levels.slice(0);
 			levelsList.sort();
 		}
@@ -364,7 +365,7 @@ class MyMap extends Component {
 			<Map
 				minZoom={MAP_MIN_ZOOM}
 				maxZoom={MAP_MAX_ZOOM}
-				className={"app-map"+(this.props.draw ? " leaflet-clickable" : "")}
+				className={"app-map" + (this.props.draw ? " leaflet-clickable" : "")}
 				ref={elem => this.elem = elem}
 				preferCanvas={false}
 				editable={true}
@@ -375,7 +376,8 @@ class MyMap extends Component {
 				boxZoom={false}
 			>
 				<AttributionControl
-					prefix={window.EDITOR_NAME+" v"+PACKAGE.version}
+					// prefix={window.EDITOR_NAME + " v" + PACKAGE.version}
+					prefix={PACKAGE.name + " v" + PACKAGE.version}
 				/>
 
 				<ScaleControl
@@ -387,10 +389,6 @@ class MyMap extends Component {
 					position="bottomright"
 				/>
 
-				{/* <SidePanelButton
-					position="topright"
-				/> */}
-
 				{[Body.MODE_EXPLORE, Body.MODE_BUILDING, Body.MODE_LEVELS, Body.MODE_FEATURES].includes(this.props.mode) && !this.state.loading && this.state.dataready && levelsList &&
 					<LevelSelector
 						position="topright"
@@ -399,10 +397,6 @@ class MyMap extends Component {
 					/>
 				}
 
-				{/* <PreviewButton
-					position="topright"
-				/> */}
-
 				{this.props.selectedBaseImagery && this._getLayer(this.props.selectedBaseImagery, this.props.baseImageryOpacity)}
 
 				{this.props.selectedOverlaysImagery && this.props.selectedOverlaysImagery.map(ol => this._getLayer(ol, this.props.overlaysImageryOpacity))}
@@ -470,57 +464,47 @@ class MyMap extends Component {
 			this._loadData();
 		}, 500);
 
-		window.mapUUID = this.props.uuid;
-
-		//静态只读map
-		Object.defineProperty(MyMap, 'map', {
-			value: this.elem.leafletElement,
-			writable: false,
-			enumerable: false,
-			configurable: false
-		});
-
 		// URL hash for map
 		this._mapHash = new L.Hash(this.elem.leafletElement);
 
 		// If no valid hash found, use default coordinates from config file or stored cookie
-		if(!window.location.hash || !window.location.hash.match(/^#\d+\/-?\d+(.\d+)?\/-?\d+(.\d+)?(\/(-?\d+(.\d+)?)?)?$/)) {
+		if (!window.location.hash || !window.location.hash.match(/^#\d+\/-?\d+(.\d+)?\/-?\d+(.\d+)?(\/(-?\d+(.\d+)?)?)?$/)) {
 			// Has cookie ?
 			const cookieHash = document.cookie.replace(/(?:(?:^|.*;\s*)lasthash\s*=\s*([^;]*).*$)|^.*$/, "$1");
 			let newHash;
 
-			if(cookieHash && L.Hash.parseHash(cookieHash)) {
+			if (cookieHash && L.Hash.parseHash(cookieHash)) {
 				newHash = cookieHash;
 			}
 			else {
-				newHash = "#"+window.CONFIG.map_initial_zoom+"/"+window.CONFIG.map_initial_latlng.join("/");
+				newHash = "#" + window.CONFIG.map_initial_zoom + "/" + window.CONFIG.map_initial_latlng.join("/");
 			}
 
 			window.history.pushState({}, "", window.location.href.split("#")[0] + newHash);
 		}
 
 		L.DomEvent.addListener(window, "hashchange", () => {
-			document.cookie = "lasthash="+window.location.hash;
+			document.cookie = "lasthash=" + window.location.hash;
 		});
 
 		this.elem.leafletElement.on("dblclick", e => {
-			if(!this.props.draw && this.props.mode !== Body.MODE_EXPLORE) {
+			if (!this.props.draw && this.props.mode !== Body.MODE_EXPLORE) {
 				PubSub.publish("body.unselect.feature");
 			}
 		});
 
 		this.elem.leafletElement.on("zoomend moveend", () => {
-			if(this.elem && this.elem.leafletElement) {
+			if (this.elem && this.elem.leafletElement) {
 				this._loadData();
 
 				const zoom = this.elem.leafletElement.getZoom();
 
-				if(zoom < window.CONFIG.data_min_zoom && (!this._lastZoom || this._lastZoom >= window.CONFIG.data_min_zoom)) {
+				if (zoom < window.CONFIG.data_min_zoom && (!this._lastZoom || this._lastZoom >= window.CONFIG.data_min_zoom)) {
 					this.elem.container.classList.add("app-map-novector");
 					PubSub.publishSync("body.unselect.feature");
-// 					PubSub.publish("body.mode.set", { mode: Body.MODE_BUILDING });
+					// 					PubSub.publish("body.mode.set", { mode: Body.MODE_BUILDING });
 				}
-				else if(zoom >= window.CONFIG.data_min_zoom && (!this._lastZoom || this._lastZoom < window.CONFIG.data_min_zoom)) {
+				else if (zoom >= window.CONFIG.data_min_zoom && (!this._lastZoom || this._lastZoom < window.CONFIG.data_min_zoom)) {
 					this.elem.container.classList.remove("app-map-novector");
 				}
 
@@ -538,7 +522,7 @@ class MyMap extends Component {
 		 * @property {int} zoom The new zoom level
 		 */
 		const alertZoom = () => {
-			if(this.elem && this.elem.leafletElement) {
+			if (this.elem && this.elem.leafletElement) {
 				PubSub.publish("map.zoom.changed", { zoom: this.elem.leafletElement.getZoom() });
 			}
 		};
@@ -553,11 +537,11 @@ class MyMap extends Component {
 		 * @property {int} [zoom] The zoom level
 		 */
 		PubSub.subscribe("map.position.set", (msg, data) => {
-			if(data.bbox) {
+			if (data.bbox) {
 				const [minlat, maxlat, minlon, maxlon] = data.bbox;
 				this.elem.leafletElement.fitBounds([[minlat, minlon], [maxlat, maxlon]]);
 			}
-			else if(data.zoom) {
+			else if (data.zoom) {
 				this.elem.leafletElement.setView(data.coordinates, data.zoom);
 			}
 			else {
@@ -574,20 +558,20 @@ class MyMap extends Component {
 	}
 
 	componentDidUpdate(fromProps) {
-		if(this.props.level !== fromProps.level) {
+		if (this.props.level !== fromProps.level) {
 			this._mapHash.setLevel(this.props.level);
 		}
 
 		const floorImgs = window.imageryManager.getFloorImages();
 
 		// Force update of floor imagery after mode change
-		if(fromProps.mode !== this.props.mode) {
+		if (fromProps.mode !== this.props.mode) {
 			this.invalidateSize();
 
 			floorImgs.forEach(img => {
 				// Check if we have a leaflet layer
-				if(this.refs["floormap_"+img.id]) {
-					this.refs["floormap_"+img.id].forceUpdate();
+				if (this.refs["floormap_" + img.id]) {
+					this.refs["floormap_" + img.id].forceUpdate();
 				}
 			});
 		}
@@ -597,8 +581,8 @@ class MyMap extends Component {
 		this.elem.leafletElement.on("mousemove", this._followMouse, this);
 
 		// Load wider area if necessary
-		if(!this.props.draw && !this.state.loading && this.elem.leafletElement.getZoom() > 19) {
-			this._loadData(this.getBounds().pad(0.5*(this.elem.leafletElement.getZoom()-19)));
+		if (!this.props.draw && !this.state.loading && this.elem.leafletElement.getZoom() > 19) {
+			this._loadData(this.getBounds().pad(0.5 * (this.elem.leafletElement.getZoom() - 19)));
 		}
 	}