1
0

2 Commits 7d1e69ce51 ... 0f443910df

Autor SHA1 Mensagem Data
  HuangKai 0f443910df app初始化增加一个中心点属性,作为坐标映射原点 há 1 semana atrás
  HuangKai c3df7e2a4b 地图暴露静态只读map对象 há 1 semana atrás
2 ficheiros alterados com 23 adições e 3 exclusões
  1. 16 1
      src/view/App.js
  2. 7 2
      src/view/Map.js

+ 16 - 1
src/view/App.js

@@ -8,6 +8,8 @@ import PresetsManager from '../ctrl/PresetsManager';
 import PubSub from 'pubsub-js';
 import VectorDataManager from '../ctrl/VectorDataManager';
 import LocationCard from './common/LocationCard';
+import { LatLng } from 'leaflet';
+import MapUtil from './utils/MapUtil';
 // import request from 'request-promise-native';
 
 
@@ -20,6 +22,19 @@ export default class App {
 		this.el = params.el
 		this.id = params.id
 		this.url = params.url
+		if(params.center){
+			this.center = new LatLng(params.center[0], params.center[1])
+		}else{
+			this.center = new LatLng(0, 0)
+		}
+
+		//静态只读m
+		Object.defineProperty(App, 'center', {
+			value: this.center,
+			writable: false,
+			enumerable: false,
+			configurable: false
+		});
 	}
 
 	init() {
@@ -48,7 +63,7 @@ export default class App {
 	 * @private
 	 */
 	_initView() {
-		ReactDOM.render(<Body uuid={this.id} />, document.getElementById(this.el));
+		ReactDOM.render(<Body uuid={this.id} center={this.center}/>, document.getElementById(this.el));
 		document.title = window.EDITOR_NAME;
 
 		// Disabling context menu

+ 7 - 2
src/view/Map.js

@@ -106,7 +106,6 @@ L.Hash.prototype.update = function() {
  * Map component handles the whole map and associated widgets.
  */
 class MyMap extends Component {
-	static map;
 	constructor() {
 		super();
 
@@ -473,7 +472,13 @@ class MyMap extends Component {
 
 		window.mapUUID = this.props.uuid;
 
-		MyMap.map = this.elem.leafletElement;
+		//静态只读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);