supermap学习系列(七)——用户自己在地图上添加点、线、面标注

学习笔记,方便以后查阅。参考资源超图地理信息云门户-示例:http://www.supermapcloud.com/online/developAPI.html

上代码:

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title></title>     <script src="libs/SuperMap.Include.js"></script>          <script type="text/javascript">            var map, layer, popup;         var featuresLayer, drawLine, drawPoint, drawPolygon, selectDrawFeature;         var drawFeatureStyle = {             strokeColor: null,             strokeWidth: null,             strokeOpacity: null,             pointRadius: 6,             fillColor: null,             fillOpacity: null,             cursor: "pointer"         };//定义要添加要素的样式          var selectStyle={             strokeColor: "#0099FF",             strokeWidth: 2,             pointerEvents: "visiblePainted",             fillColor: "#FF8247",             fillOpacity: 0.4,             pointRadius: 6,             label: "",             fontSize: 14,             fontWeight: "normal",             cursor: "pointer"         };// 点击添加的元素之后的样式         // 设置访问的GIS服务地址         var url = "http://localhost:8090/iserver/services/map-ChinaTestWorkPlace/rest/maps/ChinaTest";         function GetMap() {             // 创建地图对象             map = new SuperMap.Map("map");             //control = new SuperMap.Control.MousePosition();     //该控件显示鼠标移动时,所在点的地理坐标。             //map.addControl(control);  //添加控件              featuresLayer = new SuperMap.Layer.Vector("  test!@#  是图层的name属性             drawLine = new SuperMap.Contro

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Vue.js中使用SuperMap地图上给位布置一个半径为3km的圈,你可以按照以下步骤进行操作: 1. 首先,确保你已经按照上述步骤在Vue.js项目中引入了SuperMap的JavaScript API。 2. 在Vue.js组件的生命周期钩子函数中初始化SuperMap,并创建地图对象和图层。 ```javascript created() { // 初始化地图对象 const map = new SuperMap.Map("map", { controls: [ new SuperMap.Control.Navigation(), new SuperMap.Control.LayerSwitcher(), ] }); // 添加基础图层 const layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", "http://localhost:8090/iserver/services/map-world/rest/maps/World", { transparent: true }); map.addLayer(layer); } ``` 3. 在Vue.js组件的方法中添加一个函数来绘制圆形覆盖物。你可以使用SuperMap的API来创建一个圆形覆盖物,并添加地图上。 ```javascript methods: { drawCircle() { // 创建圆心坐标 const lon = 0; const lat = 0; const center = new SuperMap.Geometry.Point(lon, lat); // 创建圆形覆盖物 const radius = 3000; // 半径为3km const circle = new SuperMap.Feature.Vector( new SuperMap.Geometry.Polygon.createRegularPolygon(center, radius, 40, 0) ); // 设置圆形覆盖物的样式 circle.style = { fillColor: "#ff0000", fillOpacity: 0.5, strokeColor: "#ff0000", strokeOpacity: 1, strokeWidth: 2, }; // 将圆形覆盖物添加地图上 const layer = new SuperMap.Layer.Vector("CircleLayer"); layer.addFeatures(circle); this.map.addLayer(layer); } } ``` 4. 在Vue.js组件的模板中添加一个按钮,用于调用绘制圆形覆盖物的函数。 ```html <template> <div> <div id="map"></div> <button @click="drawCircle">绘制圆形</button> </div> </template> ``` 通过击按钮,就可以在地图上绘制一个半径为3km的圆形覆盖物。你可以根据需要对圆形覆盖物的样式进行修改,并添加其他功能来满足你的需求。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值