:::info 在对应的图层上,根据id进行删除 :::

一、MapGIS Desktop中查询id

删除点,首先要找到点要素的id(featureIds)

image.png

二、IG Server中查询图层

image.png

三、演示代码

  1. <body>
  2. <!-- 2、创建地图容器 -->
  3. <button onclick="deletePoint()">删除</button>
  4. <div id="map_container">
  5. </div>
  6. <!-- 3、实例化对象 -->
  7. <script>
  8. const docLayer = new Zondy.Map.Doc('', 'city', {
  9. ip: 'localhost',
  10. port: 6163
  11. })
  12. const map = new ol.Map({
  13. target: 'map_container',
  14. layers: [gaode, docLayer],
  15. view: new ol.View({
  16. projection: 'EPSG:4326',
  17. center: [114, 30],
  18. zoom: 4
  19. })
  20. })
  21. function deletePoint(){
  22. var featureIds = '13'
  23. var deleteService = new Zondy.Service.EditDocFeature(
  24. 'city',//IG Server中地图文档
  25. 2, //图层
  26. {
  27. ip:'localhost',
  28. port:'6163'
  29. }
  30. )
  31. deleteService.deletes(featureIds,onSuccess)
  32. }
  33. function onSuccess(data) {
  34. if (data.succeed) {
  35. alert('添加成功')
  36. docLayer.refresh(); //重新加载地图文档
  37. } else {
  38. alert('添加点要素失败')
  39. }
  40. }
  41. </script>
  42. </body>
  43. </html>