From: Iain Patterson Date: Thu, 7 Nov 2013 16:32:50 +0000 (-0500) Subject: Use popup div for Google Maps. X-Git-Tag: 2013-11-07^0 X-Git-Url: http://git.iain.cx/?p=readifood.git;a=commitdiff_plain;h=e2ec797398326b88782988d0b9719e21c278a584;ds=sidebyside Use popup div for Google Maps. Show an embedded Google Maps view in the popup div. It is displayed when hovering over the Map link for a preview of the map. Following the link will go to the full map on maps.google.co.uk as before. We make sure to include the output=embedded argument and specify https so that browsers don't refuse to load the preview on security grounds. --- diff --git a/lib/functions.php b/lib/functions.php index f1e7145..ec0b35a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -320,7 +320,32 @@ function get_address_map_link($address) { $postcode = trim($address->getPostcode()); if ($postcode) { - return " " . get_small_link("Map", "http://maps.google.co.uk/maps?q=" . urlencode($postcode)); + # mrt=loc specifies a location search. + $map = "maps.google.co.uk/maps?q=" . urlencode($postcode) . "&mrt=loc"; + $url = "http://$map"; + # output=embed allows display in an iframe. + # iwloc=near hides the popup window for the embedded view. + $embed = $GLOBALS['http'] . "://$map&output=embed&iwloc=near"; + $html = " "; + $html .= get_small_link_with_id("map", "Map", $url); + $html .= ""; + return $html; } }