Javascript 谷歌地图反应中的MeasureTool-缩放后测量线消失
React应用程序使用: MeasureTool结构:Javascript 谷歌地图反应中的MeasureTool-缩放后测量线消失,javascript,reactjs,google-maps,google-maps-api-3,Javascript,Reactjs,Google Maps,Google Maps Api 3,React应用程序使用: MeasureTool结构: createMeasureTool() { this.measureTool = new MeasureTool(this.props.map, { showSegmentLength: false, tooltip: false, contextMenu: false }) this.measureTool._helper.formatLength = function(v
createMeasureTool() {
this.measureTool = new MeasureTool(this.props.map, {
showSegmentLength: false,
tooltip: false,
contextMenu: false
})
this.measureTool._helper.formatLength = function(value) {
return this._formatLengthMetric(value) + " / " + this._formatLengthImperial(value * 3.28084)
}
}
在用户放大或缩小地图之前,测量效果良好。然后测量线消失,需要重新创建MeasureTool实例以再次使用测量功能。在缩放过程中,地图/测量工具/地图控件不会重新渲染
缩放后如何保留测量线?将
google react maps
从^1.1.26
更新为^1.2.26
,添加了google maps api:“^2.0.1
,解决了问题
createMeasureTool() {
this.measureTool = new MeasureTool(this.props.map, {
showSegmentLength: false,
tooltip: false,
contextMenu: false
})
this.measureTool._helper.formatLength = function(value) {
return this._formatLengthMetric(value) + " / " + this._formatLengthImperial(value * 3.28084)
}
}