Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps Rectangle method contains with bug
    text
    copied!<p>Well, I have a Google Maps instance in which I have a TraceHandler. That let the user make lines by city map. With these lines I am using google DirectionsRoute service to generate a route. The service returns various information, entre elas the *overview_path. Containing all points of directions change in my route. With these points i create triangles as follow: </p> <pre><code> var triangle; for (var indexerTrian = 0; indexerTrian &lt; self.bounds.length; indexerTrian++) { if (indexerTrian + 1 == self.bounds.length) break; var maxLng = self.bounds[indexerTrian].lng() &lt; self.bounds[indexerTrian + 1].lng() ? self.bounds[indexerTrian].lng() : self.bounds[indexerTrian + 1].lng(); var minLng = self.bounds[indexerTrian].lng() &gt; self.bounds[indexerTrian + 1].lng() ? self.bounds[indexerTrian].lng() : self.bounds[indexerTrian + 1].lng(); var latLngSouthWest = new gMap.LatLng(self.bounds[indexerTrian].lat(), maxLng); var latLngNorthEast = new gMap.LatLng(self.bounds[indexerTrian + 1].lat(), minLng); triangle= new gMap.LatLngBounds(latLngSouthWest, latLngNorthEast); self.triangles.push(triangle); } </code></pre> <p>The third part of this routine use those triangles to bring points in the route. Some code:</p> <pre><code>//for each point for (var i in result.page) { stopPoint = result.page[i]; latLng = new gMap.LatLng(stopPoint.latitude, stopPoint.longitude); //for each triangle for (var iTrian = 0; iTrian &lt; self.triangles.length; iTrian++) { //this guy verify if the stopPoint is inside the triangle. //if so. Drop it on map if (self.triangles[iTrian].contains(latLng)) { //this method just generate a Marker instance. self.SetaMarkers(latLng, iconMarker, stopPoint.descricao, true); counter++; break; } //this is a DEBUG if who prints all points if my loop comes to //end else if ((iTrian + 1) == self.triangles.length) { self.SetaMarkers(latLng, null, stopPoint.descricao, true); //break; } } } </code></pre> <p>This works good. No erros at execution. But for those triangles who I change de Longitude their <em>.contains</em> don't work. It may be a bug.</p> <p>Here is an image to demonstrate. I'm printing the triangles to debug: <a href="http://s7.postimage.org/ek3prgryj/Map.png" rel="nofollow">http://s7.postimage.org/ek3prgryj/Map.png</a> As u guys can see in the image. The <em>normal</em> red marker is those <strong>stopPoint</strong> that is out of the bounds of all triangles. And those with a edited image is the <strong>stopPoints</strong> in the bounds of some triangle.</p> <p>I have tried a lot of things already.. now im going to print the center of each triangle to see if it is where it must be.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload