Adding Mashup to PHP

Home Forums MapPress Support Adding Mashup to PHP

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #14704
    beaver
    Participant

    Hi Chris

    I am using this code and it works. What I’m trying to do now is add the mashup statement to it so I can show all the POIs on the map while retaining the existing functionality.

    $mymap = new Mappress_Map(array("center" => array("lat" => do_shortcode('[wpgc_latitude]'), "lng" => do_shortcode('[wpgc_longitude]')), "zoom" => 4, "width" => '100%'));
    echo $mymap->display();

    Where does that get added?

    Thanks

    #14706
    Chris
    Keymaster

    Hi,

    Before you can do a mashup each post needs to have a MapPress map saved to it. From the code above, it looks like you’re generating the maps on the front end.

    If you don’t already have maps saved in each post, take a look at the MapPress geocoding settings. The plugin will let you generate a map automatically in each post based on the lat/lng custom fields (once you have it configured, save or publish the posts to create a map).

    Once the maps exist, you can use do_shortcode() to add a map or a mashup shortcode to the page.

    There are examples of using do_shortcode() in the documentation. For example, a simple mashup would be:
    `

    #14707
    beaver
    Participant

    Hi Chris

    I’m already doing all that. I’m able to use the mashup shortcode in a page to create a map and show the locations.

    The issue is my code above, it does not show a mashup. I need to tell it display the mashup parameters and am not sure how to add that to the existing code above.

    In short, I need the php code to both display a mashup AND center the map around a specific location.

    #14708
    Chris
    Keymaster

    Add a query to your code to make it a mashup:

    $mymap = new Mappress_Map(array("query" => "all", "center" => array("lat" => do_shortcode('[wpgc_latitude]'), "lng" => do_shortcode('[wpgc_longitude]')), "zoom" => 4, "width" => '100%'));

    #14709
    beaver
    Participant

    Thanks, I tried that code but I got this error message:

    AJAX Error
    
    <br />
    <b>Warning</b>:  Illegal string offset 'posts_per_page' in <b>/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_query.php</b> on line <b>83</b><br />
    <br />
    <b>Warning</b>:  Illegal string offset 'map' in <b>/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_query.php</b> on line <b>110</b><br />
    <br />
    <b>Warning</b>:  Illegal string offset 'post_type' in <b>/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_query.php</b> on line <b>111</b><br />
    <br />
    <b>Warning</b>:  Illegal string offset 'cache_results' in <b>/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_query.php</b> on line <b>112</b><br />
    #14712
    Chris
    Keymaster

    Ah, I forgot – the query isn’t parsed unless it’s run through a shortcode. You can try this query:

    $mymap = new Mappress_Map(array("query" => array('post_type' => 'any', 'posts_per_page' => -1), "center" => array("lat" => do_shortcode('[wpgc_latitude]'), "lng" => do_shortcode('[wpgc_longitude]')), "zoom" => 4, "width" => '100%'));

    But I think it’s easier to just use do_shortcode():

    <?php
    $lat = do_shortcode('[wpgc_latitude]');
    $lng = do_shortcode('[wpgc_longitude]');
    
    echo do_shortcode('[mashup query="all" center="' . $lat . ',' . $lng . '" zoom="4" width="100%"]');
    ?>
    #14715
    beaver
    Participant

    Thanks Chris, that worked!

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