Maybe I didn't explain correctly but that solution doesn't work for me as I want to show polylines that have *some* part of it in the viewport, not that are completely inside the viewport.
On Feb 11, 12:02 pm, Martin <[email protected]> wrote: > If your polylines have only 2 points then you could use the GPolyline > getVertex() method to get those two points. > getVertex() returns a GLatLng > type.http://code.google.com/apis/maps/documentation/reference.html#GPolyli... > > Now use the GLatLngBounds containsLatLng() method to establish if both > points of your polyline are within the > viewport.http://code.google.com/apis/maps/documentation/reference.html#GLatLng... > > var bounds=map.getBounds(); > var myPolyline= blah blah blah; > if(bounds.containsLatLng(myPolyline.getVertex(0) && > bounds.containsLatLng(myPolyline.getVertex(1)){ > // the polyline is contained by the viewport > > } > > Martin. > > On 11 Feb, 11:36, Paulo JF Silva <[email protected]> wrote: > > > > > Hi, > > > I have polylines (that are really lines, with 2 points only) and I > > only want to show the ones that are inside the current viewport. > > > I tried using polyline.getBounds and map.getBounds, then do a > > intersect of that but polyline.getBounds gives a rectangle that > > contains the line, which means it's not very perfect. > > > Does anyone know a algorithm to do this check? (maybe if it takes into > > account that my lines have 2 vertexes only it's easier to do) > > > thanks -- You received this message because you are subscribed to the Google Groups "Google Maps API" 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-api?hl=en.
