how to associate an internal link to a marker

Hi,

Is it possible to use a google map as a menu ? I mean: I would like to create markers that would be linked to some of my pages.

thanks

  • aristath

    Hello again @Boyington,

    I'm afraid this is currently not supported out of the box.

    I have submitted a feature request for this, hopefully we'll be able to do it in a future version of the plugin.
    In the meantime, you should be able to write some custom jQuery to do this.
    If you are not comfortable with jQuery you could post a new job in our Jobs Board on https://premium.wpmudev.org/wordpress-development/ so that a skilled developer can do that for you.

    Cheers,
    Ari.

  • Philipp Stracker

    Hey Boyington, that's an interesting request!

    Since we are about to publish a small update we could manage to already introduce a new hook that allows you to intercept clicks on map-markers.
    It is quite easy to do this, but you will need to add some simple javascript code to your website.

    New javascript event "agm_google_maps-user-marker_click" is triggered when a user clicks on any marker on the map. You can listen to this event to run any javascript code you like.

    My suggestion for you is: Set the "body" of the markers to the URL that should be opened on click. Then add the following simple javascript somewhere on your page, which will redirect the user to the specified URL once he clicks on the marker:

    jQuery(function() {
    function marker_click(event, id, title, body, marker, map) {
    	alert('You clicked on a marker with this content: ' + body);
    
    	// If the marker-body looks like an URL then redirect user.
    	if ( body.match(/https?:/) ) {
    		// Instruct the browser to go to the defined URL.
    		window.location = body;
    
    		// Tells the plugin to not show the default info popup.
    		marker.show_info = false;
    	}
    }
    
    // Bind marker-clicks to the demo function above.
    jQuery(document).bind("agm_google_maps-user-marker_click", marker_click);
    });

    This feature is available in 2.8.6, which will be released today!
    If you need anything else then please let us know! Thanks again for using our map plugin :slight_smile:

    Philipp

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.