diff --git a/public/index.html b/public/index.html
index e099cd9fc..c6e160baa 100644
--- a/public/index.html
+++ b/public/index.html
@@ -48,7 +48,7 @@
toLoadJs('https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77')
}
- console.log('============调试版本:1.0.2')
+ console.log('============调试版本:1.0.3')
console.log('nodeEnv', window.SITE_CONFIG['nodeEnv'])
diff --git a/src/utils/dai-map.js b/src/utils/dai-map.js
index 2f852a730..1d2f4bb07 100644
--- a/src/utils/dai-map.js
+++ b/src/utils/dai-map.js
@@ -344,31 +344,38 @@ export default function init(ele, position, params) {
this.setMarker = function (lat, lng, title = "位置") {
lat = parseFloat(lat);
lng = parseFloat(lng);
+ const style = {
+ externalGraphic: require("@/assets/img/common/map-poi.png"),
+ graphicWidth: 32,
+ graphicHeight: 32,
+ };
if (!this.marker) {
//创建矢量图层
- var graphicLayer = new OpenLayers.Layer.Vector("graphicLayer", {
+ this.markerLayer = new OpenLayers.Layer.Vector("graphicLayer", {
style: OpenLayers.Util.extend(
{},
OpenLayers.Feature.Vector.style["default"]
),
});
- this.map.addLayer(graphicLayer);
- let pt = new OpenLayers.Geometry.Point(lng, lat);
- var style = {
- externalGraphic: require("@/assets/img/common/map-poi.png"),
- graphicWidth: 32,
- graphicHeight: 32,
- };
- var feature = new OpenLayers.Feature.Vector(pt, null, style);
- graphicLayer.addFeatures([feature]);
- this.marker = feature;
- this.markerLayer = graphicLayer;
+ this.map.addLayer(this.markerLayer);
+ this.marker = new OpenLayers.Feature.Vector(
+ new OpenLayers.Geometry.Point(lng, lat),
+ null,
+ style
+ );
+ this.markerLayer.addFeatures([this.marker]);
} else {
console.log("this marker", this.marker);
- // this.marker.geometry.x = lng;
- // this.marker.geometry.y = lat;
- this.marker.geometry = new OpenLayers.Geometry.Point(lng, lat);
-
+ this.marker.geometry.x = 0;
+ this.marker.geometry.y = 0;
+ this.marker.geometry.destroy();
+ this.markerLayer.removeFeatures([this.marker]);
+ this.marker = new OpenLayers.Feature.Vector(
+ new OpenLayers.Geometry.Point(lng, lat),
+ null,
+ style
+ );
+ // this.markerLayer.addFeatures([this.marker]);
this.markerLayer.redraw();
console.log("redraw", this.marker);
}