开发者

Point in Polygon (Google Maps API v3)

I have a google maps api v3, which uses "The Di Lab"'s plugin for polygon drawing:

http://www.the-di-lab.com/?p=219

And then uses tparkins plugin for raycasting.

https://github.com/tparkin/Google-Maps-Point-in-Polygon

However, I need to access the polygon object from the polygon plugin. The section in the polygon plugin that actually plots the Polygon on the map is:

this.polygonObj= new google.maps.Polygon({
                paths: this.coords,
                strokeColor: "#FF0000",
                strokeOpacity: 0.8,
                strokeWeight: 2,
                fillColor: "#FF0000",
                fillOpacity: 0.35,
                map:this.map
});

And I would create the map with:

var creator = new PolygonCreator(map);

I then have to do the point in polygon via calling:

var isWithinPolygon = polygonObj.containsLatLng("52,0");

So for example:

var coordinate = new google.maps.LatLng(40,90);                                                                                                                                                                                                       
var polygon = new google.maps.Polygon([], "#000000", 1, 1, "#336699", 0.3);
var isWithinPolygon = polygon.containsLatLng(coordinate开发者_C百科);

Basically all I need is the polygon object from the first script. The two javascript files are below:

http://80.229.168.62/guild_service/server/js/polygon.min.js

http://80.229.168.62/guild_service/server/js/latlngcontains.js

The page running the scripts is:

http://80.229.168.62/guild_service/server/map_view.php


If you are creating the Polygon via the creator.pen.drawPloygon() (no that's not a typo on my part--the function really is spelled that way in polygon.min.js), then you should be able to retrieve it from creator.pen.polygon.getPolygonObj().


Hi Please note the polygon creator URL has been moved to http://www.startutorial.com/articles/view/google-map-api-v3-polygon-shape-creator

:)

Regards XD
www.the-di-lab.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜