Title: Turn map marker into url link
Last modified: August 16, 2022

---

# Turn map marker into url link

 *  Resolved [Killian Santos](https://wordpress.org/support/users/killiansantos/)
 * (@killiansantos)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/)
 * Hello,
 * I tried the solution proposed in this topic [“turn map marker into url link”](https://wordpress.org/support/topic/turn-map-marker-into-url-link/#post-15358862)
   but, I did not succeed.
 * I integrated the shortcode and the JS.
 * Any ideas?
 * Killian
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fturn-map-marker-into-url-link-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15920608)
 * Please deactivate Litespeed or exclude the the js files from Leaflet Map and 
   Extensions for Leaflet Map from caching.
 *  Thread Starter [Killian Santos](https://wordpress.org/support/users/killiansantos/)
 * (@killiansantos)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15920641)
 * Hello [@hupe13](https://wordpress.org/support/users/hupe13/),
 * Thank you for your help.
 * I just deactivated LiteSpeed but it doesn’t seem to be better.
 * Killian
 *  Plugin Contributor [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15921095)
 * Okay, try and error. 😉
    Please put the the Javascript code in a html block _after_
   the `[leaflet-marker]` shortcode.
 *  Thread Starter [Killian Santos](https://wordpress.org/support/users/killiansantos/)
 * (@killiansantos)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15921132)
 * No problem [@hupe13](https://wordpress.org/support/users/hupe13/) 🙂
 * It is already the case, here is the JS present after the shortcode :
 *     ```
       <script>
       window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
       window.WPLeafletMapPlugin.push(function () {
       	var map = window.WPLeafletMapPlugin.getCurrentMap();
       	if ( WPLeafletMapPlugin.markers.length > 0 ) {
       		for (var i = 0; i < WPLeafletMapPlugin.markers.length; i++) {
       			var a = WPLeafletMapPlugin.markers[i];
       			a.on("click", function (e) {
       				if (typeof e.sourceTarget.getPopup() != "undefined") {
       					a.url = e.sourceTarget.getPopup().getContent();
       					window.location = (a.url);
       				}
       			});
       		}
       	}
       });
       </script>
   
       <script>
       window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
       window.WPLeafletMapPlugin.push(function () {
         var map = window.WPLeafletMapPlugin.getCurrentMap();
         L.control.locate({
           strings: {
             title: "Localizarme"
           }
         }).addTo(map);
       });
       </script>
       ```
   
 *  Plugin Contributor [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15921807)
 * > Please put the the Javascript code in a html block after the [leaflet-marker]
   > shortcode.
 * I cant’t see that in the source of the page.
    -  This reply was modified 3 years, 8 months ago by [hupe13](https://wordpress.org/support/users/hupe13/).
    -  This reply was modified 3 years, 8 months ago by [hupe13](https://wordpress.org/support/users/hupe13/).
 *  Thread Starter [Killian Santos](https://wordpress.org/support/users/killiansantos/)
 * (@killiansantos)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15922053)
 * You are right… I misread your message. Sorry 🙁
 * I confused [leaflet-map] with [leaflet-marker].
 * I just put the JS after all the [leaflet-marker] set and it works great!
 * Thanks a lot for your help [@hupe13](https://wordpress.org/support/users/hupe13/)
   🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Turn map marker into url link’ is closed to new replies.

 * ![](https://ps.w.org/leaflet-map/assets/icon-256x256.png?rev=1693083)
 * [Leaflet Map](https://wordpress.org/plugins/leaflet-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/leaflet-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/leaflet-map/)
 * [Active Topics](https://wordpress.org/support/plugin/leaflet-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/leaflet-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/leaflet-map/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Killian Santos](https://wordpress.org/support/users/killiansantos/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/turn-map-marker-into-url-link-2/#post-15922053)
 * Status: resolved