jasper07 / openui5-googlemaps

Openui5 Googlemaps library
MIT License
65 stars 43 forks source link

Fitbounds method #24

Closed a-feeroz closed 7 years ago

a-feeroz commented 7 years ago

Hi jasper07,

I am using this library for an aggregation binding of multiple co-ordinates on the google maps. However, if the co-ordinates are far apart, I am unable to set the zoom of the map accordingly and get all the co-ords in the same window without manual zoom.

I checked the google maps documentation and there is a method called as "fitBounds" which is used to bring all the markers in the same view. Can you please implement that in your library. I extend my contribution in this.

you can reach me on : arshadfeeroz01@gmail.com

Thank you Arshad Feeroz

jasper07 commented 7 years ago

Hi Arshad

I added a FitToMarkers feature to the Map control, If set, the zoom level is set such that all markers are brought into view. It uses the Markers position to determine the bounds of the map, if you need to do something similar for other positions, the code should give you a good idea of how it maybe implemented.

  <gmaps:Map height="250px" zoom="12" lat="-33.895" lng="151.275" fitToMarkers="true">
        <gmaps:markers>
            <gmaps:Marker lat="-33.895" lng="151.275" info="Bondi Beach" />
            ...
        </gmaps:markers>
    </gmaps:Map>

Please contribute back if you make changes you think others may find useful.

Below are links to the code, there are also related updates to demo app and unit tests

Source Map._FitToMarkers Demo Mashup Unit Test code Unit Test runner module