Saturday, January 31, 2009

Trendnet Router Restarts

Caricare markers da un database con MySQL e PHP (seconda parte)

With our review in the previous article we actually finished our work. It will indeed be included in an HTML page code that reads the XML file produced by the PHP scripts and enhance the parameters of the various methods for displaying javascript.
example uses the static method


GEvent.addListener
(marker, 'mouseover', function () {marker.openInfoWindowHtml (html)});


that activates the display on mouseover , a dialog box of a string (variable html) containing the name and description of marker

do not think there is no further comment to make if you do not have a look at the code. The result of the project You will find here .



\u0026lt;! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Strict / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\u0026lt;html xmlns="http://www.w3.org/1999/xhtml">
\u0026lt;head>
\u0026lt;meta http-equiv = "content-type" content = "text / html; charset = utf -8 "/>
\u0026lt;title> View on Google Map markers using MySQL and PHP \u0026lt;/ title>
\u0026lt;script src =" http://maps.google.com/maps?file=api&v=2&key=LAVOSTRAAPIKEY "
type = "text / javascript"> \u0026lt;/ script>
\u0026lt;script type="text/javascript">
//\u0026lt;![ CDATA [

function load () {
if (GBrowserIsCompatible ()) {
was map = new GMap2 (document.getElementById ("map" ));
map.addControl (new GLargeMapControl ());
map.addControl (new GMapTypeControl ());
map.setCenter (new GLatLng (44.0750963, 10.700323), 8);

GDownloadUrl ("creaxml.php" , function (data) {var xml =
GXml.parse (data);
were markers = xml.documentElement.getElementsByTagName ("chips");
for (var i = 0; in < markers.length; i++) {
var denom = markers [i]. getAttribute ("denom");
var address = markers [i]. getAttribute ("address");
tipomarker var = markers [i]. getAttribute ("tipomarker");
var point = new GLatLng (parseFloat (markers [i]. getAttribute ("lat")),
parseFloat (markers [i]. getAttribute ("long "))); var marker =
createMarker (point, denom, address, tipomarker) ;
map.addOverlay (marker);

}});}

}

createMarker function (point, denom, address, tipomarker) {
var marker = new GMarker(point);
var html = "("+tipomarker+")&lt;br/>&lt;b>" + denom + "&lt;/b> &lt;br/>" + indirizzo;
GEvent.addListener(marker, 'mouseover', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//]]>
&lt;/script>
&lt;/head>

&lt;body onload="load()" onunload="GUnload()">

&lt;/body>
&lt;/html>




Volendo raffinare l'applicazione, si potrebbe ad esempio visualizzare un marker di colore diverso per ogni tipologia di punto (nel nostro caso lavoro oppure studio). Il codice relativo non è molto più complicato di quanto abbiamo visto, potete fare rierimento alla già citata guida su Google Code . Oppure ci torneremo in uno dei prossimi articoli.

0 comments:

Post a Comment