[thelist] Google Map and multiple icons

Jay Blanchard jblanchard at pocket.com
Tue Apr 24 12:40:23 CDT 2007


I am using PHP to control JavaScript logic to attempt to output
different icons for different location groups. It does not display the
different icons, it displays the first icon it loads for all locations.
Can anyone see what I have done wrong? (just enough code here to
illustrate)

echo"//<![CDATA[\n";
			echo"	function onLoad() {\n";    
			echo"	   if (GBrowserIsCompatible()) {\n";
			echo"   // full map\n";
			echo"		var ssicon = new GIcon();\n";
			echo"		ssicon.image =
\"grfx/map_pocket_ss.jpg\";\n";
			echo"		ssicon.iconSize = new GSize(14,
14);\n";
			echo"		ssicon.iconAnchor = new
GPoint(0, 0);\n";
			echo"		ssicon.infoWindowAnchor = new
GPoint(5, 1);\n";
			
			echo"		var soicon = new GIcon();\n";
			echo"		soicon.image =
\"grfx/map_pocket_sp.jpg\";\n";
			echo"		soicon.iconSize = new GSize(14,
14);\n";
			echo"		soicon.iconAnchor = new
GPoint(0, 0);\n";
			echo"		soicon.infoWindowAnchor = new
GPoint(5, 1);\n";
			
			echo"		var hicon = new GIcon();\n";
			echo"		hicon.image =
\"grfx/map_pocket_h.jpg\";\n";
			echo"		hicon.iconSize = new GSize(14,
14);\n";
			echo"		hicon.iconAnchor = new GPoint(0,
0);\n";
			echo"		hicon.infoWindowAnchor = new
GPoint(5, 1);\n";
				   	
			echo"       var map = new
GMap(document.getElementById(\"map\"));\n";
			echo"	    map.centerAndZoom(new
GPoint(-98.493333,29.423889), 7);\n";
			echo"	    map.addControl(new
GLargeMapControl());\n";

			echo"		//ORIGINAL MARKER\n";

			echo"	    // function createMarker(point,
number) {\n";
			echo"		//var marker = new
GMarker(point, icon);\n";
			echo"		//var marker = new
GMarker(point);\n";
			echo"		// Show this markers index in
the info window when it is clicked\n";
			echo"		//var html = number;\n";
			echo"		//GEvent.addListener(marker,
\"click\", function() {marker.openInfoWindowHtml(html);});\n";
			echo"		//return marker;\n";
			echo"		//};\n";
			echo"		//GEvent.addListener(map,
\"click\", function(marker,point){alert(point);} );\n"; 
		
		/* display all of the store locations according to the
database */
			while($row = mysql_fetch_array($dbStore)){
				switch($row['stType']) {
					
					case "Sales Service":
					
					echo"	function
createMarker(point, number) {\n";
					echo"		var marker = new
GMarker(point, ssicon);\n";		
					echo"		var html =
number;\n";
					echo"
GEvent.addListener(marker, \"click\", function()
{marker.openInfoWindowHtml(html);});\n";
					echo"		return
marker;\n";
					echo"	};\n";
					echo "var point = new GPoint(-"
. $row['stLon'] . "," . $row['stLat'] . ");\n";
						if("" !=
$row['stPhone']){
							$dashed =
substr($row['stPhone'], 0, 3).'-'.substr($row['stPhone'], 3,
3).'-'.substr($row['stPhone'], 6, 4);
						}
					echo "var marker =
createMarker(point, '<div id=\"mapWindow\" style=\"text-align:left;
font-family: sans-serif; color: #C0004E;\"><strong>" . $row['stName'] .
"</strong><br />".$row['stStreet']."<br /></div>');\n";
					echo
"map.addOverlay(marker);\n";
					echo "\n";
					break;
					
					case "Sales":
					
					echo"	function
createMarker(point, number) {\n";
					echo"		var marker = new
GMarker(point, soicon);\n";		
					echo"		var html =
number;\n";
					echo"
GEvent.addListener(marker, \"click\", function()
{marker.openInfoWindowHtml(html);});\n";
					echo"		return
marker;\n";
					echo"	};\n";
					echo "var point = new GPoint(-"
. $row['stLon'] . "," . $row['stLat'] . ");\n";
						if("" !=
$row['stPhone']){
							$dashed =
substr($row['stPhone'], 0, 3).'-'.substr($row['stPhone'], 3,
3).'-'.substr($row['stPhone'], 6, 4);
						}
					echo "var marker =
createMarker(point, '<div id=\"mapWindow\" style=\"text-align:left;
font-family: sans-serif; color: #C0004E;\"><strong>" . $row['stName'] .
"</strong><br />".$row['stStreet']."<br /></div>');\n";
					echo
"map.addOverlay(marker);\n";
					echo "\n";



More information about the thelist mailing list