Mash Up map from different CPT

Home Forums MapPress Support Mash Up map from different CPT

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14386
    giellemme
    Participant

    Hi there,

    I’m developing a website and I created different Custom Post Types and Custom Taxonomies with views’toolset plugin. Many of these posts are somehow geolocalized but the geolocation data is provided by different Custom Fileds. Let’s say, for example, that Custom Post Types ‘Parks’ have a custom field ‘park-address’, CPT ‘Tours’ have a Custom Field ‘tour-location’, ‘Attractions’ have a Custom Field ‘attraction-address’….Is there any way to have Map Press retrieve data from different custom fields and place it on different ‘layers’? Is there any way to ‘manipulate’ the map on the front end? I mean adding checkboxes to select which data is shown/hidden on the map? When a user flags the checkbox for viewing parks POIs from CPT ‘Parks’ are shown, when checkbox for ‘Tours’ is selected also POIs for Tours are added and so on?

    Thank you

    #14387
    Chris
    Keymaster

    Hi,

    There’s no way to geocode using different fields. You’ll need to find a way to get all the data into one field (such as ‘address’). You could do that with some PHP.

    The ‘save_post’ action might work as a place to copy from one field to another. Here’s an (untested) example:

    
    function mysavepost($post_id, $post) {
      if ($post->post_type == 'tours')
        $loc = get_post_meta($post_id, 'tour-location', true);
      else if ($post->post_type == 'attraction')
        $loc = get_post_meta($post_id, 'attraction-address', true);
      endif;
      
      if ($loc)
        update_post_meta($post_id, 'address', $loc);
      else 
        delete_post_meta($post_id, 'address);
    }
    
    add_action('save_post', 'mysavepost', 100, 2);
    

    MapPress doesn’t yet support filtering (where you check boxes). You can control what is shown by using different categories on the posts and presenting different maps (i.e. a map for category A and a different map for category B).

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