LarsWiegers / laravel-maps

Your laravel maps libary.
https://github.com/LarsWiegers/laravel-maps
MIT License
254 stars 35 forks source link

Added support for LatLngBounds on Google Maps #48

Closed kopitar closed 1 year ago

kopitar commented 1 year ago

Added two attributes (boolean) to enable\disable usage of two LatLngBounds functionalities for Google Maps.

1. fitToBounds Displays the maps to fit the bounds of all used markers so that all markers on the map are visible when the map loads.

<x-maps-google
    :markers="[
        ['lat' => 46.056946, 'long' => 14.505752],
        ['lat' => 46.528753, 'long' => 12.145386],
        ['lat' => 45.454381 , 'long' => 12.145386],
        ['lat' => 45.454381, 'long' => 15.569000],
        ['lat' => 47.114349, 'long' => 13.136000]
    ]"
    :fitToBounds="true" 
></x-maps-google>

2. centerToBoundsCenter Map is centered on the exact center of all used markers.

<x-maps-google
    :markers="[
        ['lat' => 46.056946, 'long' => 14.505752],
        ['lat' => 46.528753, 'long' => 12.145386],
        ['lat' => 45.454381 , 'long' => 12.145386],
        ['lat' => 45.454381, 'long' => 15.569000],
        ['lat' => 47.114349, 'long' => 13.136000]
    ]"
    :centerToBoundsCenter="true"
   :zoomLevel="6"
></x-maps-google>

Both can be used at the same time or separately.

kopitar commented 1 year ago

Hi,

I've updated the readme.

kopitar commented 1 year ago

... plus the ability to set mapType for Google Maps (with tests, documented in README.md)

// Set type of the map (roadmap, satellite, hybrid, terrain):
<x-maps-google :mapType="'hybrid'"></x-maps-google>