提交 9b453fba authored 作者: tb53863844's avatar tb53863844

开发

上级 44b4a5ba
...@@ -17,19 +17,21 @@ class GetLocation extends Component { ...@@ -17,19 +17,21 @@ class GetLocation extends Component {
} }
map; map;
valueString; valueString;
fugai=[]
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const{lng,lat,params}=nextProps const{lng,lat,params}=nextProps
const vs = JSON.stringify({lng,lat,params}) const vs = JSON.stringify({lng,lat,params})
if(vs!=this.valueString){ if(vs!=this.valueString){
this.updateMap(lng,lat,params);
this.valueString=vs; this.valueString=vs;
if(params.setMap){
params.setMap(this.map,AMap)
}
} }
} }
updateMap=(lng,lat,params)=>{ /* updateMap=(lng,lat,params)=>{
this.map.remove(this.fugai); this.map.remove(this.fugai);
this.fugai.length = 0 this.fugai.length = 0
this.map.center=[lng ? lng : 116.397428, lat ? lat : 39.90923] this.map.setCenter([lng ? lng : 116.397428, lat ? lat : 39.90923]);
if (params && params.polygons) { if (params && params.polygons) {
for (var i = 0; i < params.polygons.length; i++) { for (var i = 0; i < params.polygons.length; i++) {
const p = params.polygons[i] const p = params.polygons[i]
...@@ -48,7 +50,7 @@ class GetLocation extends Component { ...@@ -48,7 +50,7 @@ class GetLocation extends Component {
this.fugai.push(polygon) this.fugai.push(polygon)
} }
} }
} } */
componentWillMount() { componentWillMount() {
...@@ -65,7 +67,7 @@ class GetLocation extends Component { ...@@ -65,7 +67,7 @@ class GetLocation extends Component {
***************************************/ ***************************************/
let geolocation let geolocation
const { lng, lat, params,json } = this.props const { lng, lat, params,json } = this.props
//加载地图,调用浏览器定位服务 //加载地图,调用浏览器定位服务
this.map = new AMap.Map(this.mapId, { this.map = new AMap.Map(this.mapId, {
resizeEnable: true, resizeEnable: true,
...@@ -74,7 +76,13 @@ class GetLocation extends Component { ...@@ -74,7 +76,13 @@ class GetLocation extends Component {
viewMode: '3D'//使用3D视图 viewMode: '3D'//使用3D视图
}) })
var layer1 = new AMap.TileLayer.Satellite();
var layer2 = new AMap.TileLayer.RoadNet();
var layers = [
layer1,
layer2
]
this.map.setLayers(layers);
this.map.plugin('AMap.Geolocation', () => { this.map.plugin('AMap.Geolocation', () => {
geolocation = new AMap.Geolocation({ geolocation = new AMap.Geolocation({
enableHighAccuracy: true, //是否使用高精度定位,默认:true enableHighAccuracy: true, //是否使用高精度定位,默认:true
......
...@@ -42,6 +42,8 @@ export default class location extends Component { ...@@ -42,6 +42,8 @@ export default class location extends Component {
}) })
} }
submitLocation=()=>{ submitLocation=()=>{
const {showLocation} = this.props
if(!showLocation) return;
if(isEmpty(this.state.locationMsg)&&window.lat&&window.lng){ if(isEmpty(this.state.locationMsg)&&window.lat&&window.lng){
let obj = { let obj = {
lat:window.lat, lat:window.lat,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论