Skip Navigation

[Resuelto] Map pin click goes to custom URL

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like to customize map pins (markers) so that when someone clicks a marker they are redirected to a custom URL.

Solution:
Right now there's no easy way to link to a specific URL when a marker is clicked. The easy way to handle this is to add the link inside the marker shortcode. The link will then be displayed in the marker popup. In this example I am adding a link using a URL custom field with the slug 'map-link-slug':

[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location']
[types field="map-link-slug" title="Click this link..."][/types]
[/wpv-map-marker]

To customize the marker click action instead, you would need to write your own custom JavaScript. We don't offer much support for this feature because it's an advanced customization. With that being said, you can access the Map Marker objects in JavaScript at

WPViews.view_addon_maps.markers['yourMapID']

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/
https://developers.google.com/maps/documentation/javascript/examples/event-simple

This support ticket is created hace 6 años. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Este tema contiene 8 respuestas, tiene 2 mensajes.

Última actualización por Clifford hace 6 años.

Asistido por: Christian Cox.

Autor
Mensajes
#1139205

Re: https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/

Is it possible to give a map marker a URL to go to when it's clicked?

#1139817

Right now there's no easy way to link to a specific URL when a marker is clicked. The easy way to handle this is to add the link inside the marker shortcode. The link will then be displayed in the marker popup. In this example I am adding a link using a URL custom field with the slug 'map-link-slug':

[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location']
[types field="map-link-slug" title="Click this link..."][/types]
[/wpv-map-marker]

https://toolset.com/documentation/user-guides/display-on-google-maps/
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/

To customize the marker click action instead, you would need to write your own custom JavaScript. We don't offer much support for this feature because it's an advanced customization. With that being said, you can access the Map Marker objects in JavaScript at WPViews.view_addon_maps.markers['yourMapID'].

Here's a simple click handler example on a Marker object:
enlace oculto

#1139838

Very good reply, tyvm.

Instead of a custom click handler in JS, is there a setting for the entire single map (applying to all the markers) that has all their info windows open by default?

#1139845
Screen Shot 2018-11-04 at 5.10.19 PM.png
Screen Shot 2018-11-04 at 5.10.31 PM.png

There's no setting in Views that opens all the windows by default. From what I understand only one popup is actually created, and Maps repurposes the same popup infowindow each time you click a marker. It just repositions it and replaces the contents according to the next clicked marker. So there's not a simple way to do this without some major JavaScript changes.

One other option is to insert a "Focus on marker" link in the View loop. It will appear where you place the View shortcode. You can configure the link to open the popup window when it is clicked (see the screenshots)

#1140177

I am clueless what "Focus on marker" means. Any help with understanding this?

#1140567

It's a text link that is displayed outside the map, in the View results. You can see one here:
https://christiancox-22119-rel-1.discover-wp.com/map-search/

Click "Focus on map" beneath any of the search results. Mine is set to automatically open the corresponding marker's popup, but that's optional. Otherwise it just centers the map and zooms in to the location.

#1140943

Thank you. I'd like you to log the feature request of all info windows open at same time on map.

#1141299

Okay I cannot file feature requests for you or convert an existing ticket in the current system, but feel free to create a new ticket here in the forum using the "Suggest an Improvement" option. That will log your request and get the process going. Thanks!

#1141638