i have also found this
// Poygon getBounds extension - google-maps-extensions
//
http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
if (!google.maps.Circle.prototype.getBounds) {
google.maps.Circle.prototype.getBounds = function(latLng) {
var bounds = new google.maps.LatLngBounds();
var paths = this.getPaths();
var path;
for (var p = 0; p < paths.getLength(); p++) {
path = paths.getAt(p);
for (var i = 0; i < path.getLength(); i++) {
bounds.extend(path.getAt(i));
}
}
return bounds;
}
}
// Polygon containsLatLng - method to determine if a latLng is within
a polygon
google.maps.Circle.prototype.containsLatLng = function(latLng) {
// Exclude points outside of bounds as there is no way they are in
the poly
var bounds = this.getBounds();
if(bounds != null && !bounds.contains(latLng)) {
return false;
}
// Raycast point in polygon method
var inPoly = false;
var numPaths = this.getPaths().getLength();
for(var p = 0; p < numPaths; p++) {
var path = this.getPaths().getAt(p);
var numPoints = path.getLength();
var j = numPoints-1;
for(var i=0; i < numPoints; i++) {
var vertex1 = path.getAt(i);
var vertex2 = path.getAt(j);
if (vertex1.lng() < latLng.lng() && vertex2.lng() >=
latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >=
latLng.lng()) {
if (vertex1.lat() + (latLng.lng() - vertex1.lng()) /
(vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) <
latLng.lat()) {
inPoly = !inPoly;
}
}
j = i;
}
}
return inPoly;
}
is there something like this for the .Circle?
On May 1, 5:58 pm, fireofhellx <[email protected]> wrote:
> this is my scripthttp://dannyw.instantfreesite.net/game.html
>
> ive been trying the method u have suggested and its not working for me
> im not sure why. any suggestions?
>
> it doesnt even seem to like computeDistanceBetween;
>
> On May 1, 2:17 pm, fireofhellx <[email protected]> wrote:
>
>
>
> > thanks for the information its many markers because like i said its a
> > prototype game could you explain how i would use a quad-tree structure
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.