egeloen / IvoryGoogleMapBundle

Google Map API v3 integration for your Symfony2 project.
https://github.com/egeloen/ivory-google-map
MIT License
217 stars 152 forks source link

Marker as links #141

Closed Sashkan closed 8 years ago

Sashkan commented 9 years ago

I noticed the "clickable" option on the markers, is it possible to configure them as link ? I have a map with a few cities, I'd like to link them to some HTML links.

Thank you, and great work !

egeloen commented 8 years ago

I would use this answer: http://stackoverflow.com/questions/8769966/google-map-api-open-url-by-clicking-at-marker#answer-8770321

Build a marker with a extra param:

$marker = new Marker();
$marker->setOption('url', 'your-url-data');

And then attach an event for each marker

$map->getEventManager()->addEvent(new Event(
    $marker->getVariable(),
    MouseEvent::CLICK,
    'function () { window.location.href = this.url; }'
))