Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Creating a custom legend #98

Open
cowtan opened this issue Jan 12, 2018 · 2 comments
Open

Creating a custom legend #98

cowtan opened this issue Jan 12, 2018 · 2 comments

Comments

@cowtan
Copy link

cowtan commented Jan 12, 2018

Can you tell me if it's possible to create a custom legend for a map (like this https://developers.google.com/maps/documentation/javascript/adding-a-legend)? I can't see a way of doing it but I'm not enough on expert on Google Maps or your library to be sure.

Thanks.

@almirb
Copy link
Contributor

almirb commented Apr 25, 2018

Hello!

You can do It like this:

$map = new \dosamigos\google\maps\Map([
                    'zoom' => 14,
                    'name' => 'mapaEcossistema',   <---- Put a name in your map
                    'width' => '100%',
                    'height' => '710',
                    'tilt' => 45,
                    'styles' => new \yii\web\JsExpression("[{ featureType: 'poi',  elementType: 'labels', stylers: [{ visibility: 'off' }] } ]"),
                ]);

After placing the markers, create the legend html and enable It by JS:

        $js = <<<JS
            legenda = document.getElementById('legenda');                             
            mapaEcossistema.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(legenda);
JS;

        $map->appendScript($js);

The legend will be added aside the map. :)

@paskuale75
Copy link

paskuale75 commented Oct 15, 2021

@almirb with this logic I can customize the markers too ? Some example ?
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants