Home › Forums › MapPress Support › Adding a POI to a Mappress Map generated by a PHP Query › Reply To: Adding a POI to a Mappress Map generated by a PHP Query
Hi Tom,
When you use a query, the map POIs are read from the database and any POIs specified statically are ignored, that’s probably why you’re not seeing the additional marker.
One approach that may work is to modify the POIs before they’re sent back to the map. You can use filter ‘mappress_map_display’ for that purpose – it’s passed each map just before the map is displayed, so you could probably add a POI there. I haven’t tested this, but here’s how it might look in functions.php:
function mypoi($map) {
$map->pois[] = new Mappress_Poi(array(“iconid” => “green-dot”, “title” => “My Location”, “point” => array(“lat” => $_SESSION[‘lat’], “lng” => $_SESSION[‘long’])));
}
add_action('mappress_map_display', 'mypoi');
Alternatively, you could use javascript to get a handle to the map and add a marker to it. For example if the map is named ‘mapp0’ (the default name for this 1st map, you can override it in the shortcode) the javascript would be:
var gmap = mapp0.getMap();
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var marker = new google.maps.Marker({
position: myLatlng,
map: gmap,
title: 'Hello World!'
});