You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.5 KiB
72 lines
2.5 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var polygonsData_js_1 = require("./polygonsData.js");
|
|
Component({
|
|
data: {
|
|
longitude: 120.39053363,
|
|
latitude: 36.29732416,
|
|
mapScale: 15.5,
|
|
polygons: [],
|
|
markers: []
|
|
},
|
|
lifetimes: {
|
|
attached: function () {
|
|
console.log('map-polygons attached');
|
|
this.setData({
|
|
polygons: polygonsData_js_1.getPolygonsDatas()
|
|
});
|
|
this.addMarkers();
|
|
},
|
|
detached: function () {
|
|
console.log('map-polygons detached');
|
|
},
|
|
},
|
|
methods: {
|
|
addMarkers: function () {
|
|
var _this = this;
|
|
var marker = {
|
|
id: 0,
|
|
iconPath: '',
|
|
width: 1,
|
|
height: 2,
|
|
};
|
|
this.data.polygons.forEach(function (markerPoint, index) {
|
|
var newMarker = Object.assign({}, marker, {
|
|
id: markerPoint.id,
|
|
longitude: markerPoint.marker[0],
|
|
latitude: markerPoint.marker[1],
|
|
iconPath: '../../images/pos.png',
|
|
label: {
|
|
content: markerPoint.label,
|
|
color: '#fff',
|
|
fontSize: 16,
|
|
borderWidth: 1,
|
|
borderRadius: 4,
|
|
bgColor: markerPoint.labelFillColor,
|
|
borderColor: "#cccccc00",
|
|
padding: 4,
|
|
display: "ALWAYS",
|
|
textAlign: "center",
|
|
},
|
|
});
|
|
_this.data.markers.push(newMarker);
|
|
});
|
|
this.setData({
|
|
markers: this.data.markers
|
|
});
|
|
},
|
|
bindClickMap: function (e) {
|
|
var selectItem = polygonsData_js_1.isSelectPolygon(e.detail);
|
|
this.mapCtx = wx.createMapContext("device-map", this);
|
|
var label = selectItem.label ? selectItem.label + '-' + e.detail.name : '';
|
|
if (e.detail.name) {
|
|
var destination = e.detail.name.indexOf('号楼') > -1 ? label : e.detail.name;
|
|
this.mapCtx.openMapApp({
|
|
longitude: e.detail.longitude,
|
|
latitude: e.detail.latitude,
|
|
destination: destination
|
|
});
|
|
}
|
|
},
|
|
}
|
|
});
|
|
|