Changed API > Need Mashup based on custom fields

Home Forums MapPress Support Changed API > Need Mashup based on custom fields

Tagged: , ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19591
    jcdesign
    Participant

    Hi there,

    I started with version 2.75.1, and rolled my own custom map, essentially a mashup, based on a “businesses” custom post type. The map allowed me to filter based on a custom taxonomy, first as the page was loaded (e.g., “Dining”), then by clicking on various business types (e.g., “Mexican”).

    I was probably reinventing the wheel, but in any case, it relied on resetting POIs using mapp0.setPois(), which no longer exists in your newer update.

    I’m happy to use the mashup block instead, but I can’t get this to even load the first map. If I could do that, I believe I could alter the filtering via AJAX and deal with the rest.

    I have the query like this:

    {
        "post_type": [
            "is"
         ],
        "tax_query": {
            "ldba_type": {
                "taxonomy": "ldba_type",
                "terms": [
                    243
                ],
                "operator": "IN",
                "include_children": true
            }
        }
    }

    The lat/lng for each business is stored as a custom field, ‘latlng’, with value like this:

    39.97684,-105.13226

    I tried adding this custom field to the mashup, but similarly got no results. What am I missing here?

    Thanks!

    Of note: I’m working with a Full Site Editing theme. I disabled all plugins except for the code generating the appropriate custom post types/taxonomies, and changed to Twenty Twenty Two theme, but still no results.

    Also possibly notable: every time I try to view the shortcode for the Mashup, the block gets corrupted, and I see “This block has encountered an error and cannot be previewed.”

    #19592
    jcdesign
    Participant

    Also tried a simpler query, no results

    {
        "post_type": [
            "is"
         ]
    }
    #19593
    Chris
    Keymaster

    Hi,

    That JSON doesn’t look valid.  MapPress uses the WordPress wp_query module, so those are the parameters that are supported.

    Instead of entering raw JSON, try just using the post type using the checkboxes for the mashup block.  That should give something like this (for a ‘location’ custom post type):

    {
    "post_type": [
    "location"
    ]
    }

    It’s not possible to generate a mashup directly from custom fields.  You have to first create a map for each post, based on the custom fields.  Once the individual post maps exist, you can create a mashup combining all of the maps together.

    https://mappresspro.com/mappress-documentation/#toc-generating-maps-from-custom-fields

    I was able to reproduce the crash when displaying the shortcode, which occurs because the JSON is invalid, and it’ll be fixed ASAP in version 2.83.8.  Thanks for reporting it!

    #19594
    jcdesign
    Participant

    I really don’t want to need a map for each post! Will keep digging. The JSON was auto-generated. I wasn’t trying to enter the JSON, just thought that could help point in the right direction. Thanks!

    #19596
    Chris
    Keymaster

    Ok.

    I’ve removed the buggy shortcode tab for the mashup block.  It worked for earlier versions, but the block now supports queries that are too complex to use in a shortcode.

    I don’t know how the invalid JSON was created, but if you’d like to provide a step-by-step I’ll try to reproduce the problem.

    I know what you mean about not wanting a map for each post, but those maps don’t need to be displayed – they just need to exist and be linked to the post in order to generate a mashup.

    The maps are now React components, so JavaScript methods like setPois are no longer present.  But it’s still possible to set the POIs from PHP.  Filter ‘mappress_post_query’ can be used to modify the results for a mashup map.  The filter is applied when a mashup query is run, see plugin file ‘\pro\mappress_query.php’.  The filter is called with a map object and the original query, and you can use it to set the POIs for the map.

    If you need more info, please let me know.

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