openlayer 判斷一個點是不是在一個面內

獲取的到的是面的數據格式是在這裏插入圖片描述
需要先轉成polygon。

let _points = JSON.parse(that.hotZone).coordinates
    this.polygonFeature = new Feature({
    geometry: new Polygon(_points)
})

然後在點擊map的singleclick裏面

	let geo = that.polygonFeature.getGeometry()
	that.isIn = geo.intersectsCoordinate(that.clickPoint);   // clickPoint爲map點擊的座標
	if(that.isIn) {
    console.log("該mark點在當前幾何元素裏。");
}`
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章