Multiple markers at same location not showing up with php map

Home Forums MapPress Support Multiple markers at same location not showing up with php map

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #16080

    Hi Chris,

    I’m generating my own mashup maps on pages with custom queries showing cutom post types of events.

    The reason I can’t use the [mashup] shortcode is because the location information is stored in a location record that is associates with the event and not the event record itself.

    I am using Advanced Custom Fields (ACF) plugin to allow the user to select a location for an event – so there is a relationship between the event and the location. An ACF map field is used in the location record and that geocodes the latitude and longitude for the address – which I can access.

    When I loop through the events in my query I list them on the page and also build my pois for a map showing multiple events/locations.

    The code looks like this…

    $eventtitle = '<a href="' . get_permalink() . '" title="' . get_the_title() .'">' . get_the_title() . '</a>';
    $locid = get_field( 'pn_event_location' ); //from event record
    if ( $locid ) { // ID of location record
    $locname = get_the_title( $locid ); //from location record
    $locstreet = get_field( 'pn_location_street', $locid);
    $loccity = get_field( 'pn_location_city', $locid );
    $locstate = get_field( 'pn_location_state', $locid );
    $loczip = get_field( 'pn_location_zip', $locid );
    $locmap = get_field( 'pn_location_map', $locid ); // map field from location record
    if ( $locmap ) {
    $loclat = $locmap['lat'];
    $eventpois[$mapcount] = new Mappress_Poi(array("title" => $eventtitle, "body" => $locname . "</br>" . $locstreet . "</br>" . $loccity . ", " . $locstate . " " . $loczip, "point" => array("lat" => $loclat, "lng" => $loclng)));

    At the end of the loop I display the map…

    if ( $mapcount ) {
    $pneventmap = new Mappress_Map();	
    $pneventmap->pois = $eventpois ; 
    echo $pneventmap->display(array("directions"=>"none"));	

    Works great except when there are two or more event records in the query at the same location. Then it only shows the first one even though I load them all into the array.

    Is there a setting or filter I can use to make sure a marker is displayed for each event?





    There’s nothing in the plugin to prevent display of two markers at the same location, but if they are in exactly the same place they’ll display on top of each other (you’ll have two entries in the POI list, though). One solution for that might be to slightly stagger the markers lat/lng by a random amount, or drag them slightly when you save the maps.

    It is on my enhancement list to handle multiple markers in a single infowindow, but it’s difficult to implement and I don’t have any ETA for it yet.

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