Support » Plugin: Interactive Geo Maps » Populating RoundMarkers

  • Resolved Johnny

    (@johnexposureninja)


    Hello,

    I’m trying to populate a map using the tutorial here – https://interactivegeomaps.com/docs/available-filters-to-manipulate-data/

    However I’m not using regions in this map but want the venues to show as round markers (I guess icon markers are available in the Pro version?)

    This is my code but no venues are showing on the map. Can you point out where I went wrong please?

    add_filter( 'igm_add_meta', 'igm_cpt_addon_venues', 1 );
    function igm_cpt_addon_venues( $meta ){
    	if ( intval( $meta['id'] ) !== 1253 ) {
    		return $meta;
    	}
    	
    	$venueObjects = [];
    	
    	$args = array(
    		'posts_per_page' => -1,
    		'post_status'    => 'publish',
    		'post_type'      => 'venue',
    	);
    
    	$venues = get_posts( $args );
    	
    	foreach ( $venues as $venue ) {
    		$venueID = $venue->ID;
    		$tooltipContent = wp_trim_words( $venue->post_content, 20, "..." );
    		$latitude = get_field('location', $venueID)['latitude'];
    		$longitude = get_field('location', $venueID)['latitude'];
    		
    		$entry = array(
    			'title'          => $venue->post_title,
    			'tooltipContent' => $tooltipContent,
    			'content'        => get_permalink( $venueID ),
    			'useDefaults'    => '1',
    			'action'         => 'open_url',
    			'latitude'       => $latitude,
    			'longitude'      => $longitude
    		);
    		
    		array_push( $venueObjects, $entry );
    	}
    
    	$meta['roundMarkers'] = $venueObjects;
    	return $meta;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Carlos Moreira

    (@carlosmoreirapt)

    Hi @johnexposureninja
    Looking at the code, it seems to be correct. Maybe it’s just missing the id property, the $entry array. Can you check if that’s the issue? The id could be the venue id also.

    (yes, icon markers are available in the pro version only).
    Greetings, Carlos

    Thread Starter Johnny

    (@johnexposureninja)

    @carlosmoreirapt Added the id but no luck still.

    This is how the markers appear (top left corner) – https://snipboard.io/IH0hpu.jpg
    I also clicked on the marker so you can see it contains the correct coordinates.

    Here’s the amended code:

    function igm_cpt_addon_venues( $meta ){
    	if ( intval( $meta['id'] ) !== 1253 ) {
    		return $meta;
    	}
    	
    	$venueObjects = [];
    	
    	$args = array(
    		'posts_per_page' => -1,
    		'post_status'    => 'publish',
    		'post_type'      => 'venue',
    	);
    
    	$venues = get_posts( $args );
    	
    	foreach ( $venues as $venue ) {
    		$venueID = $venue->ID;
    		$tooltipContent = '<div class="venue-tooltip-wrapper"><div class="venue-tooltip-image">' . get_the_post_thumbnail( $venueID, "thumbnail" ) . '</div><div class="venue-tooltip-description"><h6>' . $venue->post_title . '</h6><p>' . wp_trim_words( $venue->post_content, 20, "..." ) . '</p></div></div>';
    		$latitude = get_field('location', $venueID)['latitude'];
    		$longitude = get_field('location', $venueID)['longitude'];
    		
    		$entry = array(
    			'id' 			 => $venueID,
    			'name'           => $venue->post_title,
    			'tooltipContent' => $tooltipContent,
    			'content'        => get_permalink( $venueID ),
    			'useDefaults'    => '1',
    			'action'         => 'open_url',
    			'latitude'       => $latitude,
    			'longitude'      => $longitude
    		);
    		
    		array_push( $venueObjects, $entry );
    	}
    
    	$meta['roundMarkers'] = $venueObjects;
    	return $meta;
    }
    Thread Starter Johnny

    (@johnexposureninja)

    @carlosmoreirapt Figured it out. The latitude & longitude are entered in a coordinate array.

    $entry = array(
    	'id' 			 => $venueID,
    	'name'           => $venue->post_title,
    	'tooltipContent' => $tooltipContent,
    	'content'        => get_permalink( $venueID ),
    	'useDefaults'    => '1',
    	'coordinates'	 => array('latitude' => $latitude, 'longitude' => $longitude,),
    );
    Plugin Author Carlos Moreira

    (@carlosmoreirapt)

    Hi @johnexposureninja
    Glad you manage to figure it out, thank you for sharing the solution. Sorry for having overlooked that. Thank you for using the plugin once again!
    Cheers, Carlos

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.