vue+openlayers5学习总结(七)vue封装的一些功能

本文总结了在Vue项目中使用OpenLayers5进行地图测量和GeoJSON对象拖拽功能的封装,详细介绍了在vue中调用封装的measure.js文件进行操作的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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");
    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值