[Phphtmllib-devel] SF.net SVN: phphtmllib:[3155] branches/BRANCH_2_X/phphtmllib
Status: Beta
Brought to you by:
hemna
|
From: <mpw...@us...> - 2008-09-11 08:53:08
|
Revision: 3155
http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3155&view=rev
Author: mpwalsh8
Date: 2008-09-11 08:53:18 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Added ability to set InfoText on GoogleMap widget.
Modified Paths:
--------------
branches/BRANCH_2_X/phphtmllib/examples/widget24.php
branches/BRANCH_2_X/phphtmllib/widgets/GoogleMap.inc
Modified: branches/BRANCH_2_X/phphtmllib/examples/widget24.php
===================================================================
--- branches/BRANCH_2_X/phphtmllib/examples/widget24.php 2008-09-10 19:42:38 UTC (rev 3154)
+++ branches/BRANCH_2_X/phphtmllib/examples/widget24.php 2008-09-11 08:53:18 UTC (rev 3155)
@@ -39,7 +39,7 @@
$gm1->set_style("border: 3px solid #afb5ff") ;
$gm1->setAddress("1600 Pennsylvania Ave, Washington DC, 20006") ;
$gm1->setShowControls(true) ;
- $gm1->setShowInfoWindow(true) ;
+ $gm1->setInfoWindowType(PHL_GMAPS_INFO_WINDOW_PLAIN) ;
$gm1->setZoomLevel(10) ;
// Get Google Maps key from URI
@@ -60,7 +60,7 @@
$address = join($gm1->getAddress(), "<br>") ;
$container->add(html_h4("Map Controls: On", html_br(),
- "Info Window: On", html_br(), "Zoom Level: 10", html_br(),
+ "Info Window: On - Plain", html_br(), "Zoom Level: 10", html_br(),
"Map Type: Off", html_br(), sprintf("Address: %s", $address))) ;
$container->add($gm1) ;
@@ -74,7 +74,7 @@
$gm2->setAddress("Buckingham Palace London SW1A 1, United Kingdom") ;
$gm2->setShowType(true) ;
$gm2->setShowControls(false) ;
- $gm2->setShowInfoWindow(false) ;
+ $gm1->setInfoWindowType(PHL_GMAPS_INFO_WINDOW_NONE) ;
$gm2->setZoomLevel(15) ;
// Get Google Maps key from URI
@@ -105,7 +105,7 @@
$gm3->setAddress("1600 Pennsylvania Ave, Washington DC, 20006") ;
$gm3->setAddress("Buckingham Palace London SW1A 1, United Kingdom") ;
$gm3->setShowControls(true) ;
- $gm3->setShowInfoWindow(true) ;
+ $gm1->setInfoWindowType(PHL_GMAPS_INFO_WINDOW_HTML) ;
$gm3->setZoomLevel(2) ;
// Get Google Maps key from URI
@@ -119,7 +119,7 @@
$gm3->generateMap() ;
$container->add(html_h4("Map Controls: Off", html_br(),
- "Info Window: Off", html_br(), "Zoom Level: 2", html_br(),
+ "Info Window: On - HTML", html_br(), "Zoom Level: 2", html_br(),
"Map Type: Off", html_br(), sprintf("Address: %s", $address))) ;
$container->add($gm3) ;
Modified: branches/BRANCH_2_X/phphtmllib/widgets/GoogleMap.inc
===================================================================
--- branches/BRANCH_2_X/phphtmllib/widgets/GoogleMap.inc 2008-09-10 19:42:38 UTC (rev 3154)
+++ branches/BRANCH_2_X/phphtmllib/widgets/GoogleMap.inc 2008-09-11 08:53:18 UTC (rev 3155)
@@ -20,6 +20,10 @@
*
*/
+define("PHL_GMAPS_INFO_WINDOW_NONE", "none") ;
+define("PHL_GMAPS_INFO_WINDOW_PLAIN", "plain") ;
+define("PHL_GMAPS_INFO_WINDOW_HTML", "html") ;
+
/**
* Google Map class
*
@@ -40,6 +44,11 @@
var $_address = array() ;
/**
+ * Info Text to display
+ */
+ var $_infotext = array() ;
+
+ /**
* Show Google Maps type, off by default
*/
var $_show_type = false ;
@@ -52,7 +61,7 @@
/**
* Show Google Maps Info Window, on by default
*/
- var $_show_info_window = true ;
+ var $_info_window_type = true ;
/**
* Google Map width in pixels, 450 by default
@@ -80,7 +89,8 @@
var $_head_js_code = "
google.load('maps', '2');
- function phl_gmap_load(zoom, type, control, infowindow, canvas, addresses)
+ function phl_gmap_load(zoom, type, control,
+ infowindowtype, canvas, addresses, infowindowtext)
{
if (google.maps.BrowserIsCompatible())
{
@@ -88,7 +98,7 @@
// Hide the info window?
- if (!infowindow)
+ if (infowindowtype == '%s')
{
map.disableInfoWindow();
}
@@ -97,14 +107,14 @@
if (type)
{
- map.addControl(new GMapTypeControl());
+ map.addControl(new google.maps.MapTypeControl());
}
// Show the map controls?
if (control)
{
- map.addControl(new GSmallMapControl());
+ map.addControl(new google.maps.SmallMapControl());
}
// Create the GeoCoder
@@ -115,15 +125,16 @@
for (var i = 0 ; i < addresses.length ; i++)
{
- phl_show_address(map, geocoder, addresses[i], zoom);
+ phl_show_address(map, geocoder, addresses[i],
+ infowindowtext[i], zoom, infowindowtype) ;
}
}
}
- function phl_show_address(map, geocoder, address, zoom)
+ function phl_show_address(map, geocoder,
+ address, zoom, infowindowhtml, infowindowtext)
{
- geocoder.getLatLng(
- address,
+ geocoder.getLatLng(address,
function(latlng)
{
if (!latlng)
@@ -135,10 +146,19 @@
map.setCenter(latlng, zoom);
var marker = new google.maps.Marker(latlng);
map.addOverlay(marker);
- GEvent.addListener(marker, \"click\", function() {
- marker.openInfoWindow(address);
- });
- marker.openInfoWindow(address);
+ google.maps.Event.addListener(marker, \"click\",
+ function()
+ {
+ if (infowindowtype == '%s')
+ {
+ marker.openInfoWindowHtml(infowindowtext);
+ }
+ else
+ {
+ marker.openInfoWindow(infowindowtext);
+ }
+ });
+ //marker.openInfoWindow(address);
map.checkResize();
}
}
@@ -162,7 +182,8 @@
*/
function getHeadJSCode()
{
- return $this->_head_js_code ;
+ return sprintf($this->_head_js_code,
+ PHL_GMAPS_INFO_WINDOW_NONE, PHL_GMAPS_INFO_WINDOW_HTML) ;
}
/**
@@ -206,6 +227,26 @@
}
/**
+ * Set the info text to display
+ *
+ * @param string - info text to display
+ */
+ function setInfoText($infotext)
+ {
+ $this->_infotext[] = $infotext ;
+ }
+
+ /**
+ * Get the info text to display
+ *
+ * @return mixed - info text to display
+ */
+ function getInfoText()
+ {
+ return $this->_infotext ;
+ }
+
+ /**
* Set the width of the map
*
* @param int - width of the map
@@ -310,9 +351,9 @@
*
* @param boolean - show info window state of the map
*/
- function setShowInfoWindow($show = true)
+ function setInfoWindowType($show = true)
{
- $this->_show_info_window = $show ;
+ $this->_info_window_type = $show ;
}
/**
@@ -320,9 +361,9 @@
*
* @return boolean - show info window state of the map
*/
- function getShowInfoWindow()
+ function getInfoWindowType()
{
- return $this->_show_info_window ;
+ return $this->_info_window_type ;
}
/**
@@ -392,7 +433,7 @@
$this->getZoomLevel(),
$this->getShowType() ? "true" : "false",
$this->getShowControls() ? "true" : "false",
- $this->getShowInfoWindow() ? "true" : "false",
+ $this->getInfoWindowType(),
$this->get_id(), $addrarg)) ;
$this->add($js) ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|