首页 / 浏览问题 / WebGIS / 问题详情
几何查询,只能绘制多边形,不能显示查询的点
5EXP 2023年04月17日
几何查询,只能绘制多边形,不能显示查询的点

1个回答

您好,请问您这边有具体定位是几何查询没有返回有效的查询结果为空,

还是查询结果正确但是添加到地图上不成功,

如果是后者的话您在地图上绘制查询结果几何对象具体用的是什么接口呢?

希望可以帮助到您。
9,963EXP 2023年04月17日

报这种错误vue.esm.js:3767  TypeError: geometry.getVertices is not a function

<template>
  <div class="query">
    <shiliangmap />
    <div class="search-wrapper">
      <el-input
        class="search"
        size="small"
        v-model="datasql"
        placeholder="请输入土地位置"
      ></el-input>
      <el-button class="btn" size="small" type="primary" @click="dataquery"
        >搜索</el-button
      >
      <el-button class="btn" size="small" type="primary" @click="pointquery"
        >几何查询</el-button
      >
      <el-button class="btn" size="small" type="primary" @click="clearMap"
        >清除</el-button
      >
    </div>
  </div>
</template>

<script>
import shiliangmap from "../common/shiliangmap.vue";
export default {
  components: { shiliangmap },
  name: "Mapsysmanage3Chaxun",

  data() {
    return {
      map: null,
      resultLayer:null,
      polygon: null,
      isDrawing: false,
      url: "http://localhost:8090/iserver/services/data-JiZhunDiJia/rest/data"
    };
  },

  mounted() {
    this.pointquery();
  },

  methods: {
    pointquery() {
      this.map = this.$store.getters._getDefaultshiliangmap;
      if (this.isDrawing) {
        return;
      }
      this.isDrawing = true;
      this.map.on("click", this.addPointToPolygon);
      this.map.on("dblclick", this.stopDrawing);
      this.polygon = L.polygon([], { color: "#409EFF" }).addTo(this.map);
      var geometryParam = new L.supermap.GetFeaturesByGeometryParameters({
        datasetNames: ["基准地价:基准地价"],
        geometry: this.polygon.toGeoJSON(),
        spatialQueryMode: "INTERSECT"
      });
      new L.supermap.FeatureService(this.url).getFeaturesByGeometry(
        geometryParam,
        serviceResult => {
          this.resultLayer = L.geoJSON(serviceResult.result.features, {
            onEachFeature: function(feature, layer) {
              layer.bindPopup(":" + feature.properties.项目位置);
            }
          }).addTo(this.map);
        });
      },
    addPointToPolygon(e) {
      this.polygon.addLatLng(e.latlng);
    },
    stopDrawing() {
      this.map.off("click", this.addPointToPolygon);
      this.map.off("dblclick", this.stopDrawing);
      this.isDrawing = false;
    },
    clearMap() {
      if (this.polygon) {
        this.map.removeLayer(this.polygon);
        this.polygon = null;
        this.isDrawing = false; // 将isDrawing标志设置为false
      }
    }
  }
};
</script>

<style>
.query {
  width: 100%;
  height: 100%;
  position: relative;
}
.search-wrapper {
  position: absolute;
  top: 70px; /* 距离顶部的距离 */
  right: 100px; /* 距离右侧的距离 */
  display: flex; /* 使用 Flex 布局 */
  align-items: center; /* 垂直居中 */
  z-index: 100;
}
.btn {
  margin-left: 10px;
}
</style>

您好,看您报错信息是 vue报的 geometry.getVertices 方法未定义,您这边有定位测试具体是哪个接口或代码使用后才出现该报错吗?
...