Browse Source

看地页面,看地详情地图修改

master
王健 4 years ago
parent
commit
ba36532e4e
  1. 104
      pages/look-detail/look-detail.js
  2. 6
      pages/look-detail/look-detail.wxml
  3. 8
      pages/look/look.js

104
pages/look-detail/look-detail.js

@ -41,8 +41,8 @@ Page({
list: {},
more: []
},
latitude: '',
longitude: '',
latitude: '29.56',
longitude: '106.58',
basisInfo: {},
seniorInfo: {},
polygons: [],
@ -51,17 +51,17 @@ Page({
mid: '',
},
//定位当前
gotoLocation(id) {
$api.AJAX('GET', 'applets/landlistedlonlat/list/' + id, true).then(res => {
var latitude = res.data[0].landLonLat.split(';')[0].split(',')[0]
var longitude = res.data[0].landLonLat.split(';')[0].split(',')[1]
this.setData({
latitude: longitude,
longitude: latitude,
})
})
// gotoLocation(id) {
// $api.AJAX('GET', 'applets/landlistedlonlat/list/' + id, true).then(res => {
// var latitude = res.data[0].landLonLat.split(';')[0].split(',')[0]
// var longitude = res.data[0].landLonLat.split(';')[0].split(',')[1]
// this.setData({
// latitude: longitude,
// longitude: latitude,
// })
// })
},
// },
setMark(e) {
let {
markShow
@ -117,30 +117,18 @@ Page({
$api.AJAX('GET', 'applets/landlistedlonlat/list/' + id, {
landListedId: id
}, true).then(res => {
console.log(res.data);
centerPoint = res.data[0].centerPoint;
geom = res.data[0].geom;
//======================
// console.log(geom)
let polygon = this.wkt2polygon(geom);
polygon.strokeColor = '#fe00fe';
polygon.strokeWidth = 2;
polygon.fillColor = '#00fe04' + util.ten2XO(50);
let polygons = [polygon];
let point = WKT.parse(centerPoint);
console.log(point.coordinates)
this.setData({
polygons,
latitude: point.coordinates[1],
longitude: point.coordinates[0],
})
console.log(res);
if(res.data.length>0){
centerPoint = res.data[0].centerPoint;
this.setWKT1(res, 2)
let point = WKT.parse(centerPoint);
this.setData({
latitude: point.coordinates[1],
longitude: point.coordinates[0],
})
}
})
$api.getLandDetail(this.data.landListedId).then(res => {
for (let key in res.data) {
if (!res.data[key]) {
@ -165,6 +153,52 @@ Page({
})
},
//复制了一份,因为参数问题
setWKT1(data, id) {
let {
polygons
} = this.data;
let newPolygons = data.data.map(item => {
console.log(item);
let geomPoints = WKT.parse(item.geoms || item.geom);
console.log(geomPoints);
let points = [];
geomPoints.coordinates[0].forEach(ele => {
if (typeof (ele[0]) === 'number') {
points.push({
longitude: ele[0],
latitude: ele[1]
})
} else {
points = ele.map(once => {
let lonlat = {
longitude: once[0],
latitude: once[1]
}
return lonlat
})
}
})
let strokeColor = '' + item.lineColor + util.ten2XO(item.lineOpaqueness);
let strokeWidth = item.strokeWidth ? Number(item.strokeWidth) : 2;
let fillColor = '' + item.fillColor + util.ten2XO(item.fillOpaqueness);
let polygon = {
points,
strokeColor,
strokeWidth,
fillColor,
zIndex: 1,
id
}
return polygon
});
// polygons = polygons.concat(newPolygons);
this.setData({
polygons:polygons.concat(newPolygons)
})
},
wkt2polygon(geom) {
let geomPoints = WKT.parse(geom);
let points = [];
@ -239,7 +273,7 @@ Page({
landListedId: options.id,
mid: options.mid
})
this.gotoLocation(this.data.landListedId);
// this.gotoLocation(this.data.landListedId);
this.getData(options.id)
if (active) {
active = Number(active);

6
pages/look-detail/look-detail.wxml

@ -39,11 +39,11 @@
<text class="look-top-text">土地池</text>
</view>
</view> -->
<map class="map" polygons="{{polygons}}" latitude="{{latitude}}" longitude="{{longitude}}">
<cover-view slot="callout">
<map class="map" polygons="{{polygons}}" latitude="{{latitude}}" longitude="{{longitude}}" scale="13">
<!-- <cover-view slot="callout">
<cover-view marker-id="1"></cover-view>
<cover-view marker-id="2"></cover-view>
</cover-view>
</cover-view> -->
</map>
<view class="gener">
<view class="gener-top">

8
pages/look/look.js

@ -926,9 +926,9 @@ Page({
}
return polygon
});
polygons = polygons.concat(newPolygons);
// polygons = polygons.concat(newPolygons);
this.setData({
polygons
polygons:polygons.concat(newPolygons)
})
},
//复制了一份,因为参数问题
@ -970,9 +970,9 @@ Page({
}
return polygon
});
polygons = polygons.concat(newPolygons);
// polygons = polygons.concat(newPolygons);
this.setData({
polygons
polygons:polygons.concat(newPolygons)
})
},

Loading…
Cancel
Save