1.封装测量及拖拽geojson功能
vue中使用方法
self.source = new VectorSource({
wrapX: true });
//var measurevector =measure.vector(self.source);
var dragAndDropInteraction = new DragAndDrop({
formatConstructors: [GPX, GeoJSON, IGC, KML, TopoJSON]
});
dragAndDropInteraction.on("addfeatures", function(event, mymap) {
var vectorSource = new VectorSource({
features: event.features
});
self.map.addLayer(
new VectorLayer({
renderMode: "image",
source: vectorSource
})
);
self.map.getView().fit(vectorSource.getExtent());
});
this.map = new Map({
controls: mapcontrols,
target: mapcontainer,
interactions: defaultInteractions({
constrainResolution: true, onFocusOnly: true}).extend([
dragAndDropInteraction,
new PinchZoom({
constrainResolution: true
}),
]),
layers: [
new TileLayer({
source: new OSM(),
name: "世界地图(OSM瓦片)"
}),
measure.vector(self.source)
],
view: myview
});
methods: {
//删除测量痕迹
removemeasure(){
measure.removemeasuretip(this);
this.selected("None");