检查LatLong是否在多边形内

时间:2013-02-20 09:23:43

标签: javascript google-maps-api-3 openlayers

我有一个人的lat和lon,我需要找到这个人在特定多边形的内部或外部。因为我使用KML矢量叠加来显示openlayers谷歌地图上的区域。请咨询

1 个答案:

答案 0 :(得分:1)

In your init: function()

//Awesome design
style = { styleMap: new OpenLayers.StyleMap({ "temporary": style})};

//Make the layer        
this.selectLayer = new OpenLayers.Layer.Vector("draw_polygon", style);

//Make the control
this.selectControl = new OpenLayers.Control.DrawFeature(this.selectLayer, OpenLayers.Handler.Polygon, {featureAdded: this.toggleDraw});

whatever.map.addControl(this.selectControl);

Then:

toggleDraw: function(feature) {
//Do some magic with finding if the uses is inside (example) search_options.viewModel.searchForPerson(feature);
}

我担心我不能给你完整的代码,但你明白了。

相关问题