Javascript 检查LatLong是否位于多边形内

Javascript 检查LatLong是否位于多边形内,javascript,google-maps-api-3,openlayers,Javascript,Google Maps Api 3,Openlayers,我得到了一个人的纬度和经度,我需要找到这个人在一个特定多边形的内部或外部。因为我使用KML矢量叠加在openlayers谷歌地图上显示区域。请给出建议 In your init: function() //Awesome design style = { styleMap: new OpenLayers.StyleMap({ "temporary": style})}; //Make the layer this.selectLayer = new OpenLayers.La

我得到了一个人的纬度和经度,我需要找到这个人在一个特定多边形的内部或外部。因为我使用KML矢量叠加在openlayers谷歌地图上显示区域。请给出建议

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);
}
恐怕我不能给你完整的代码,但你明白了