Search code examples
phpwordpresswordpress-geo-mashup

In GEO-MASHUP: How to open post directly when marker is clicked?


I created a contextual map to show posts of a certain category on a map. I would like the post to open directly when the user clicks on the marker on the map. How can I achieve this?

Geo-Mashup : Version 1.6.2 WordPpress version: WordPress 3.5.1

Thanks!


Solution

  • You must install the plugin Geo Mashup Custom. After that, access the plugin folder and create a js file. If you are using google v3 api create file custom-googlev3.js and then copy paste this code:

    GeoMashup.addAction( 'selectedMarker', function( properties, marker, map ) {
      var objects = GeoMashup.getMarkerObjects( marker );
      if ( objects.length > 0 && GeoMashup.have_parent_access ) {
        parent.location.href = properties.home_url + '?p=' + objects[0].object_id;
      }
    });
    

    Please also read the JavaScript API reference.