On 12 May 2011 14:12, Ben Appleton <apple...@google.com> wrote:
> It sounds like you have a polygon containment forest: a collection of rooted
> trees whose roots are outer polygons, children are polygonal holes,
> grand-children are polygonal islands inside holes, etc. You can certainly
> represent containment in JavaScript, but it's not necessary for rendering.
> Therefore the Google Maps API does not represent containment.
>
> There is an unfortunate caveat. Many browsers use Canvas to render vector
> graphics, and Canvas requires that outer vs inner polygons have opposite
> orientations - it implements only "zero-winding fill". For example, if your
> outer boundary is clockwise, your holes must be counter-clockwise, islands
> within holes must be clockwise, and so on. If you need to determine the
> orientation of a polygon you can use the geometry library's
> computeSignedArea method
> (http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical).
> You can then traverse your containment tree to ensure that outer vs inner
> polygons have opposite sign, reversing polygonal loops to negate their sign
> where necessary.
>
> Incidentally the geometry library also has a method to encode
> polylines/polygons in the same format as you reference, but compiled so it
> loads faster.
>
> So I suggest: use google.maps.Polygon to visualize your polygons, but wrap
> it in another class or datastructure to represent your containment forest.
> To visualize simply add the google.maps.Polygon to the map. When
> constructing queries to your server, consult your wrapper class /
> datastructure to determine which polygonal loops are outside vs inside.
> Optionally, also switch to using the compiled poly encoder in the geometry
> library.
>
> Hope that helps
> Ben
>
> On May 12, 2011 9:54 PM, "Richard Quadling" <rquadl...@gmail.com> wrote:
>
> --
> 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 google-maps-js-api-v3@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-api-v3+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

Thanks for that.

encodePath only allows for a single path, not a set of paths. I'm
simply concatenating them with | (pipe). And splitting and decoding
them in PHP.  How do I access the compiled encoder. I'm currently
using google.maps.geometry.encoding.encodePath()

Very useful. -ve values from computeSignedArea() relate to the outer
polygons and +ve values to the inner ones.

I think the final piece for me now is to determine from 2 polygons if
one is completely within the other.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to