[Google Maps] FitToBounds not working - even in demo screen perparation

Forge Component
(29)
Published on 2018-10-18 by Labs
29 votes
Published on 2018-10-18 by Labs

Hi, 

I've noticed that in your example of multiple map markers "http://apps.outsystems.com/GoogleMapsDemo/MultipleMarkers.aspx" the initial map is not correctly fitting to the multiple marker bounds and only shows the last point of interest added. 

Interestingly it appears to update the bounds correctly if you save an individual point of interest but the initial screen prep does not work.....given I've copied this example I'd love to know how to fix this so an initial screen prep can rescale the map to fit the multiple marker bounds. 

Please let me know thanks,

Barney :-) 


Solution

Ok I've figured out why this behaviour occurs - the loop within the multiple markers screen preparation is calling AddAddressMarkerToMap which under the hood of Google maps causes it to reset the bounds. See https://stackoverflow.com/questions/11336405/google-maps-api-v3-fitbounds-after-multiple-geocoder-requests so the solution is to use AddCoordinateMarkerToMap within the loop and all works as it should. 

Barney :-) 

Solution

Hi Barney,

Great to hear you fixed the problem you where having.

Kind regards,
Martijn