bradcornford / Googlmapper

An easy way to integrate Google Maps with Laravel
MIT License
464 stars 142 forks source link

custom marker for informationWindow? #295

Closed wivaku closed 6 years ago

wivaku commented 6 years ago

How do I set the marker details for a specific informationWindow?

The below shows the informationWindow with default marker ('default marker title' with red dot), instead of custom marker details ('marker: town hall' with yellow dot).

        Mapper::map(53.3799491,-1.4706869, [
            'zoom' => 16,
            'center' => true, // true so the zoom will be used
            'marker' => false, // don't show marker for this location
            'markers' => [
                'title' => 'default marker title', 
                'icon' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752125_en_v0' // red dot
            ],
        ]);

        Mapper::informationWindow(
            53.3799491,-1.4706869, 
            'town hall',
            [
                'marker' => true,
                'markers' => [
                    'title' => 'marker: town hall', 
                    'icon' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752063_en_v0' // yellow dot
                ],
            ]
        );

        return view('map');    
cloudwales commented 6 years ago
Mapper::informationWindow(-1.11111, 11.11111,[
        'marker' => true,
        'markers' => [
            'symbol' => 'circle',
            'icon' => /path/to/your/icon.png'',
            'autoclose' => true,
            'animation' => 'DROP'
        ]
);

Or

Mapper::map(-1.11111, 11.11111,[
        'markers' => [
            'symbol' => 'circle',
            'icon' => /path/to/your/icon.png'',
            'animation' => 'DROP'
    ],   
]);
wivaku commented 6 years ago

Do you have a working example? The above does not show a specific marker title or a custom marker for that specific informationWindow. (Plus: it is missing required 3rd argument: informationWindow content)

bradcornford commented 6 years ago

Hi @wivaku,

The following should work:

        Mapper::map(53.3799491,-1.4706869, [
            'zoom' => 16,
            'center' => true, // true so the zoom will be used
            'marker' => false, // don't show marker for this location
            'markers' => [
                'title' => 'default marker title', 
                'icon' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752125_en_v0' // red dot
            ],
        ]);

        Mapper::informationWindow(
            53.3799491,-1.4706869, 
            'town hall',
            [
                'marker' => true,
                    'title' => 'marker: town hall', 
                    'icon' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752063_en_v0' // yellow dot
            ]
        );

        return view('map');    
wivaku commented 6 years ago

that's it. great, thanks.

ulver2812 commented 4 years ago

Hi @wivaku,

The following should work:

        Mapper::informationWindow(
            53.3799491,-1.4706869, 
            'town hall',
            [
                'marker' => true,
                    'title' => 'marker: town hall', 
                    'icon' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752063_en_v0' // yellow dot
            ]
        );

        return view('map');    

@bradcornford, It is possible to set the icon size in the above code?

bradcornford commented 4 years ago

@ulver2812 Yes, this is possible as follows:

Mapper::informationWindow(
            53.3799491,-1.4706869, 
            'town hall',
            [
                'marker' => true,
                    'title' => 'marker: town hall', 
                    'icon' => [
'url' => 'https://storage.googleapis.com/support-kms-prod/SNP_2752063_en_v0',
'scale' => 20
            ]
        );

        return view('map');