I have a site with GPS and made my own routeplanner. The GPS marker is at the center of the map. Every time the directionsDisplay.setDirections(response) is called its jumping to fit,bounds and back to the GPS marker. I want to stop the fit.bounds of directionsDisplay and stick to the GPS marker. Is that possible?

没有正确的解决方案

其他提示

I know this is old but there is a property "preserveViewport" in the directions renderer options that you can set to true.

I got same issue, but I didn't find a way to prevent Maps API to 'bounds' to the route. As a workaround, I let Maps do it, and after a timout, then I set my own 'bound'. Here is a sample code of this:

function zoomOnMarkers(arrayMarkers){
  var bounds = new google.maps.LatLngBounds ();
  for (var i=0, nCount=arrayMarkers.length; i<nCount; i++) {
    bounds.extend(arrayHomesMarker[arrayHomes[i].id].getPosition());
  }
  map.fitBounds(bounds);    
}
setTimeout(function () { zoomOnMarkers(myArrayOfMarkers); }, 2000);

I'm not happy with that, as it may fail if it takes more than 2 secs to display the map (due to poor network conditions), but that's better than nothing.I'll get back on this one to find a better solution when less pressure...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top