Home › Forums › MapPress Support › Adding Mashup to PHP
Tagged: mashup
- This topic has 6 replies, 2 voices, and was last updated 9 years, 4 months ago by
beaver.
-
AuthorPosts
-
May 16, 2014 at 8:37 pm #14704
beaver
ParticipantHi 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
May 17, 2014 at 4:55 am #14706Chris
KeymasterHi,
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:
`May 17, 2014 at 8:32 am #14707beaver
ParticipantHi 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.
May 17, 2014 at 9:10 am #14708Chris
KeymasterAdd 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%'));
May 17, 2014 at 3:37 pm #14709beaver
ParticipantThanks, 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 />
May 18, 2014 at 6:01 am #14712Chris
KeymasterAh, 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%"]'); ?>
May 18, 2014 at 4:26 pm #14715beaver
ParticipantThanks Chris, that worked!
-
AuthorPosts
- You must be logged in to reply to this topic.