Vue项目使用ArcGIS JS添加PictureMarkerSymbol

之前添加外部的图片作为symbol时图片路径一直有问题。有两种方式,一种是图片放到nginx或tomcat里,在symbol的url里使用绝对路径,这种适合图片可能动态增加或修改的情况。另一种如下

  private addPoint(angle: number) {
    this.view.graphics.removeAll();
    const symbol = {
      type: 'picture-marker',
      url: require('../assets/images/icon.png'), // require返回的直接是base64Url
      width: '120px',
      height: '120px',
      angle,
    };
    // mapView对象
    this.view.graphics.add(
      arcgisFuns.Graphic({
        // 一个point geometry
        geometry: this.point.center,
        symbol,
      })
    );
  }

使用require返回相对路径下图片的base64Url

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Vue 项目使用 ArcGIS API for JavaScript 添加 WMTS 服务和 GeoJSON 格式图层的步骤如下: 1. 安装 ArcGIS API for JavaScript: ``` npm install --save @arcgis/core ``` 2. 在 Vue 组件中引入 ArcGIS API for JavaScript: ``` import * as ArcGIS from "@arcgis/core"; ``` 3. 在 Vue 组件中创建地图和视图: ``` <template> <div ref="mapViewNode" style="height: 100vh;"></div> </template> <script> export default { name: "MapView", data() { return { mapView: null } }, mounted() { this.initializeMap(); }, methods: { async initializeMap() { const [Map, MapView] = await ArcGIS.loadModules(["esri/Map", "esri/views/MapView"]); const map = new Map({ basemap: "streets-navigation-vector" }); const mapView = new MapView({ container: this.$refs.mapViewNode, map: map, zoom: 12, center: [-118.805, 34.027] }); this.mapView = mapView; } } }; </script> ``` 4. 在 `initializeMap` 方法中添加 WMTS 服务和 GeoJSON 格式图层: ``` async initializeMap() { const [Map, MapView, WMTSLayer, GeoJSONLayer] = await ArcGIS.loadModules(["esri/Map", "esri/views/MapView", "esri/layers/WMTSLayer", "esri/layers/GeoJSONLayer"]); const map = new Map({ basemap: "streets-navigation-vector" }); const mapView = new MapView({ container: this.$refs.mapViewNode, map: map, zoom: 12, center: [-118.805, 34.027] }); const wmtsLayer = new WMTSLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS", id: "WorldTimeZones", title: "World Time Zones", activeLayer: { id: "WorldTimeZones" } }); map.add(wmtsLayer); const geoJsonLayer = new GeoJSONLayer({ url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson" }); map.add(geoJsonLayer); this.mapView = mapView; } ``` 注意:在添加 WMTS 服务和 GeoJSON 格式图层时需要确保服务和数据源的坐标系信息一致,否则可能会导致图层位置不正确。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值