• Resolved RobertBrisbane

    (@robertbrisbane)


    Hi Dylan,

    I have a question with regards to the ‘Show on Map’ Reference Tag.

    <?php echo GeoMashup::show_on_map_link() ?>

    Here is my setup:

    1. I am using a map on the search results page. The page now displays a list of the search results on one side and the map displays the individual markers for the search results on the other side.

    2. I would like to now click on individual search results in the list to highlight the corresponding marker on the map without navigating away from the map. If I use the above reference tag it navigates away from the current page and opens the link in a new page.

    I am a bit lost and tried to set up something but it didn’t work. Please let me know if I missed something and if there is a simple solution to this. If this however involves a lot of work please let me know.

    kind regards,
    Rob

    P.S. Thank you again for this amazing plugin and all the work you have put into this. This has been such a helpful tool to my open source research project. I hope I can repay you one day ??

    https://www.ads-software.com/plugins/geo-mashup/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter RobertBrisbane

    (@robertbrisbane)

    ok so I’m working on it ??

    the solution is somewhere in here

    /**
    	 * A template tag to insert a link to a post on the mashup.
    	 *
    	 * @see show_on_map_link()
    	 */
    	public static function post_link($option_args = '') {
    		return self::show_on_map_link($option_args);
    	}
    
    	/**
    	 * A template tag to return an URL for the current location on the
    	 * global map page.
    	 *
    	 * @since 1.3
    	 * @todo What would happen if the global map is not a post map?
    	 *
    	 * @param string|array $args Template tag arguments.
    	 * @return string The URL, empty if no current location is found.
    	 */
    	public static function show_on_map_link_url( $args = null ) {
    		global $geo_mashup_options;
    
    		$defaults = array( 'zoom' => '' );
    		$args = wp_parse_args( $args, $defaults );
    
    		$args = array_filter( $args );
    
    		$url = '';
    		$location = self::current_location_guess();
    
    		if ( $location ) {
    			$url = get_page_link($geo_mashup_options->get('overall', 'mashup_page'));
    
    			if ( !$url )
    				return '';
    
    			$args['center_lat'] = $location->lat;
    			$args['center_lng'] = $location->lng;
    
    			if ( $geo_mashup_options->get( 'global_map', 'auto_info_open' ) == 'true' )
    				$args['open_object_id'] = $location->object_id;
    
    			$url = htmlentities( add_query_arg( $args, $url ) );
    		}
    		return $url;
    	}
    
    	/**
    	 * A template tag to insert a link to the current location post on the
    	 * global map page.
    	 *
    	 * @since 1.3
    	 *
    	 * @param string|array $args Tag arguments.
    	 * @return string The link HTML, empty if no current location is found.
    	 */
    	public static function show_on_map_link( $args = null ) {
    		$defaults = array( 'text' => __( 'Show on map', 'GeoMashup' ),
    			 'display' => false,
    			 'zoom' => '',
    			 'show_icon' => true );
    		$options = wp_parse_args($args, $defaults);
    		$link = '';
    		$url = self::show_on_map_link_url( $args );
    		if ( $url ) {
    			$icon = '';
    			if ($options['show_icon'] && strcmp( $options['show_icon'], 'false' ) != 0) {
    				$icon = '<img src="'.GEO_MASHUP_URL_PATH.
    					'/images/geotag_16.png" alt="'.__('Geotag Icon','GeoMashup').'"/>';
    			}
    			$link = '<a class="gm-link" href="'.$url.'">'.
    				$icon.' '.$options['text'].'</a>';
    			if ($options['display']) {
    				echo $link;
    			}
    		}
    		return $link;
    	}
    
    	/**
    	 * Visible posts list template tag.
    	 *
    	 * Returns a placeholder where a related map should display a list
    	 * of the currently visible posts.
    	 *
    	 * @since 1.2
    	 * @link https://code.google.com/p/wordpress-geo-mashup/wiki/TagReference#Visible_Posts_List
    	 *
    	 * @param string|array $args Template tag arguments.
    	 * @return string Placeholder HTML.
    	 */
    	public static function visible_posts_list($args = null) {
    		$args = wp_parse_args($args);
    
    		$list_html = '';
    
    		$for_map = 'gm-map-1';
    		if ( !empty( $args['for_map'] ) ) {
    			$for_map = $args['for_map'];
    		}
    		if ( !empty( $args['heading_text'] ) ) {
    			$heading_div = '<div id="' . $for_map . '-visible-list-header" style="display:none;">';
    			$heading_tags = '<h2>';
    			if ( !empty( $args['heading_tags'] ) ) {
    				$heading_tags = $args['heading_tags'];
    			}
    			$list_html .= balanceTags( $heading_div . $heading_tags . $args['heading_text'], true );
    		}
    		$list_html .= '<div id="' . $for_map . '-visible-list"></div>';
    		return $list_html;
    	}
    
    	/**
    	 * List located posts template tag.
    	 *
    	 * Returns an HTML list of all located posts.
    	 *
    	 * @since 1.1
    	 * @link https://code.google.com/p/wordpress-geo-mashup/wiki/TagReference#List_Located_Posts
    	 *
    	 * @param string|array $option_args Template tag arguments.
    	 * @return string List HTML.
    	 */
    	public static function list_located_posts( $option_args = null ) {
    		$option_args = wp_parse_args( $option_args );
    		$option_args['object_name'] = 'post';
    		$list_html = '<ul class="gm-index-posts">';
    		$locs = GeoMashupDB::get_object_locations( $option_args );
    		if ($locs) {
    			foreach ($locs as $loc) {
    				$list_html .= '<li><a href="'.get_permalink($loc->object_id).'">'.
    					$loc->label."</a></li>\n";
    			}
    		}
    		$list_html .= '</ul>';
    		return $list_html;
    	}
    Plugin Author Dylan Kuhn

    (@cyberhobo)

    Hi Rob,

    Thanks for the kind words! There’s a feature request for this that has not been implemented yet, but also includes some template code to do it:

    https://github.com/cyberhobo/wordpress-geo-mashup/issues/601

    Thread Starter RobertBrisbane

    (@robertbrisbane)

    Hi Dylan,

    Thank you for your quick responds. This is amazing ?? Thank you so much. This was exactly what I was looking for and it works perfectly.

    I will tick this one as resolved.

    Thank you again ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show on Map link for search results’ is closed to new replies.