|
@@ -169,9 +169,8 @@ class MyMap extends Component {
|
|
* 修改地图状态
|
|
* 修改地图状态
|
|
*/
|
|
*/
|
|
setView(center, zoom) {
|
|
setView(center, zoom) {
|
|
- let latlng = L.latLng(center)
|
|
|
|
if (this.elem && this.elem.leafletElement) {
|
|
if (this.elem && this.elem.leafletElement) {
|
|
- this.elem.leafletElement.setView(latlng, zoom);
|
|
|
|
|
|
+ this.elem.leafletElement.setView(center, zoom);
|
|
// this.setState({
|
|
// this.setState({
|
|
// center: latlng,
|
|
// center: latlng,
|
|
// zoom: zoom
|
|
// zoom: zoom
|
|
@@ -181,9 +180,8 @@ class MyMap extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setCenter(center) {
|
|
setCenter(center) {
|
|
- let latlng = L.latLng(center)
|
|
|
|
if (this.elem && this.elem.leafletElement) {
|
|
if (this.elem && this.elem.leafletElement) {
|
|
- this.elem.leafletElement.setView(latlng, this.state.zoom);
|
|
|
|
|
|
+ this.elem.leafletElement.pathTo(center);
|
|
// this.setState({
|
|
// this.setState({
|
|
// center: latlng
|
|
// center: latlng
|
|
// })
|
|
// })
|
|
@@ -250,9 +248,9 @@ class MyMap extends Component {
|
|
/**
|
|
/**
|
|
* @param {Array} [10, 20] [-20, 10]
|
|
* @param {Array} [10, 20] [-20, 10]
|
|
*/
|
|
*/
|
|
- pathTo(offsetPix) {
|
|
|
|
|
|
+ pathTo(center) {
|
|
if (this.elem && this.elem.leafletElement) {
|
|
if (this.elem && this.elem.leafletElement) {
|
|
- this.elem.leafletElement.pathTo(offsetPix)
|
|
|
|
|
|
+ this.elem.leafletElement.pathTo(center)
|
|
} else {
|
|
} else {
|
|
console.error('pathTo')
|
|
console.error('pathTo')
|
|
}
|
|
}
|
|
@@ -262,9 +260,8 @@ class MyMap extends Component {
|
|
* @param {Number} zoom 18
|
|
* @param {Number} zoom 18
|
|
*/
|
|
*/
|
|
flyTo(center, zoom) {
|
|
flyTo(center, zoom) {
|
|
- let latlng = L.latLng(center)
|
|
|
|
if (this.elem && this.elem.leafletElement) {
|
|
if (this.elem && this.elem.leafletElement) {
|
|
- this.elem.leafletElement.flyTo(latlng, zoom)
|
|
|
|
|
|
+ this.elem.leafletElement.flyTo(center, zoom)
|
|
} else {
|
|
} else {
|
|
console.error('flyTo')
|
|
console.error('flyTo')
|
|
}
|
|
}
|
|
@@ -325,7 +322,8 @@ class MyMap extends Component {
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
async _loadData(bounds) {
|
|
async _loadData(bounds) {
|
|
- if (this.props.datalocked || (window.CONFIG.always_authenticated && !window.editor_user)) {
|
|
|
|
|
|
+ // (this.props.datalocked || (window.CONFIG.always_authenticated && !window.editor_user))
|
|
|
|
+ if (this.props.datalocked) {
|
|
return new Promise(resolve => {
|
|
return new Promise(resolve => {
|
|
setTimeout(() => resolve(this._loadData(bounds)), 100);
|
|
setTimeout(() => resolve(this._loadData(bounds)), 100);
|
|
});
|
|
});
|
|
@@ -442,7 +440,7 @@ class MyMap extends Component {
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
<Map
|
|
<Map
|
|
- center={L.latLng(this.props.center)}
|
|
|
|
|
|
+ center={this.props.center}
|
|
zoom={this.props.zoom}
|
|
zoom={this.props.zoom}
|
|
minZoom={this.props.minZoom}
|
|
minZoom={this.props.minZoom}
|
|
maxZoom={this.props.maxZoom}
|
|
maxZoom={this.props.maxZoom}
|
|
@@ -547,7 +545,14 @@ class MyMap extends Component {
|
|
*/
|
|
*/
|
|
_followMouse(e) {
|
|
_followMouse(e) {
|
|
this._mouseCoords = e.latlng;
|
|
this._mouseCoords = e.latlng;
|
|
- // console.log(this._mouseCoords)
|
|
|
|
|
|
+ // console.log(e.latlng)
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * @private
|
|
|
|
+ */
|
|
|
|
+ _MouseClick(e) {
|
|
|
|
+ this._mouseCoords = e.latlng;
|
|
|
|
+ // console.log(e.latlng)
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
@@ -596,7 +601,7 @@ class MyMap extends Component {
|
|
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");
|
|
this.elem.container.classList.add("app-map-novector");
|
|
PubSub.publishSync("body.unselect.feature");
|
|
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");
|
|
this.elem.container.classList.remove("app-map-novector");
|
|
@@ -608,6 +613,8 @@ class MyMap extends Component {
|
|
|
|
|
|
// Follow mouse position
|
|
// Follow mouse position
|
|
this.elem.leafletElement.on("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.on("mousemove", this._followMouse, this);
|
|
|
|
+ // Mouse Click position
|
|
|
|
+ this.elem.leafletElement.on("click", this._MouseClick, this);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Event for map zoom changes
|
|
* Event for map zoom changes
|
|
@@ -689,6 +696,10 @@ class MyMap extends Component {
|
|
// });
|
|
// });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Mouse Click position
|
|
|
|
+ this.elem.leafletElement.off("click", this._MouseClick, this);
|
|
|
|
+ this.elem.leafletElement.on("click", this._MouseClick, this);
|
|
|
|
+
|
|
// Follow mouse position
|
|
// Follow mouse position
|
|
this.elem.leafletElement.off("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.off("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.on("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.on("mousemove", this._followMouse, this);
|
|
@@ -701,6 +712,7 @@ class MyMap extends Component {
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
PubSub.unsubscribe("map");
|
|
PubSub.unsubscribe("map");
|
|
|
|
+ this.elem.leafletElement.off("click", this._MouseClick, this);
|
|
this.elem.leafletElement.off("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.off("mousemove", this._followMouse, this);
|
|
this.elem.leafletElement.off("load");
|
|
this.elem.leafletElement.off("load");
|
|
this.elem.leafletElement.off("zoomend");
|
|
this.elem.leafletElement.off("zoomend");
|