| Home  | Casa  | Hardware  | Networking  | Programmazione  | Software  | Domanda  | Sistemi  |   
Programmazione  
  • C /C + + Programming

  • Computer Programming Languages

  • Delphi Programming

  • Java Programming

  • Programmazione Javascript

  • PHP /MySQL Programmazione

  • Perl Programming

  • Python Programming

  • rubino Programmazione

  • Nozioni di base di Visual Programming
  •  
    Conoscenza Informatica >> Programmazione >> PHP /MySQL Programmazione >> Content
    Come iniziare una applicazione Google Maps con PHP
    Per iniziare una applicazione Google Maps con PHP , è necessario creare uno script PHP che sarà in uscita i dati necessari per l'applicazione Google Maps in un formato XML . È quindi necessario creare le funzionalità delle applicazioni di Google Maps con HTML e Javascript e chiamare lo script PHP per recuperare i dati necessari per la mappa. Opzionalmente si può incapsulare l' intera applicazione Google Maps all'interno di un file PHP , piuttosto che all'interno di un file HTML , per includere logica aggiuntiva . Istruzioni , creare script PHP
    1

    Creare una classe PHP per memorizzare coordinate di latitudine e longitudine e una descrizione . Ad esempio, digitare :

    < php
    class

    coordinate {

    pubblica $ latitudine, longitudine $ , $ descrizione ;

    public function __ construct ( ? $ lat , $ lng , $ descrizione) {

    $ this - > latitudine = $ lat ;

    $ this-> longitudine = $ lng ;

    $ questo - > descrizione = $ descrizione ;

    }

    }
    2

    Creare una classe PHP per memorizzare una serie di coordinate associate a un nome identificativo e la descrizione. Aggiungere una funzione per la classe per produrre una versione XML dei dati . Ad esempio, digitare :
    classe

    coordinate {

    protetto $ coordinate ;

    public function __ construct ( ) {

    $ this - > coordinate = array (); }


    Aggiungi funzione pubblica ( $ nome , $ descrizione , $ lat , $ lng ) {

    $ this-> coordinate [ $ name ] = nuove coordinate ( lat $ , $ lng , $ descrizione) ;

    }

    output_xml funzione pubblica ( ) {

    $ xml = new DOMDocument ( "1.0" ) ; < br

    $ node > = $ xml- > createElement ( "marcatori" ) ;

    $ root = $ xml- > appendChild ( $ node ) ;

    foreach ( $ this -> coordinate a partire da $ chiave = > $ valore ) {

    $ nodo = $ xml- > createElement ( "marcatore " ) ;

    $ newnode = $ root- > appendChild ( $ node ) ;

    $ newnode - > setAttribute ( " città" , $ key ) ;

    $ newnode - > setAttribute ( " lat " , $ valore > di latitudine ) ;

    $ newnode - > setAttribute ( " lng" , $ valore > longitudine ) ;

    $ newnode - > setAttribute ( " desc" , $ valore > descrizione ) ;

    }

    echo $ xml- > saveXML (); }


    }
    3 < p > Creare il programma PHP principale per memorizzare la latitudine e la longitudine per le città e l'uscita di una versione XML di questi dati durante l'esecuzione del programma selezionato . Ad esempio, digitare :

    $ citta = new Coordinate ( ) ;

    $ città - > add ( " Nassau " , " Bahamas " , " 25,08,333 mila " , " -77,3333 " ) ;

    $ città - > add ( " Cairo " , "Egitto" , " 36,01,667 mila " , " 31,2333 ");

    $ città - > add ( "Paris " , " Francia " , " 48,83,333 mila " , " 2,33333 ");

    $ città - > add ( "Pechino " , "Cina" , " 39,91,667 mila " , " 116,3333 ");

    $ città - > , aggiungere ( " Santiago" , " Cile " , " -33,40000 " , " -70,66667 ");

    $ città - > output_xml (); ?

    >

    , creare Google Maps Application
    4

    Creare un nuovo file PHP se si desidera includere la logica PHP con il programma principale . Creare le intestazioni HTML per la pagina web. Ad esempio, digitare : < ? Php

    $ custom_name = " Steve " ;

    >


    < ! DOCTYPE html >



    < meta http - equiv = contenuto "Content-Type " = "text /html ; charset = utf- 8" ? />

    < php echo $ custom_name ; ? > 's Mappa delle Internazionale Città < /title> <br> 5 <p> includere la libreria esterna di Google Maps API javscript . Ad esempio, digitare : <br> <p> <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"> < /script > ; <br> 6 <p> Creare il programma principale Javascript. Inizia la sceneggiatura con la creazione di una variabile per memorizzare la mappa . Ad esempio, digitare : <br> <p> <script type="text/javascript"> <br> <p> var map ; <br> 7 <p> creare una funzione per visualizzare la mappa su lo schermo . Per iniziare, definire le opzioni per la mappa . Creare la mappa e creare una variabile per la finestra pop-up informativo . Ad esempio, digitare : <br> funzione <p> creare ( ) { var <br> <p> newYork = new google.maps.LatLng ( 40,69847032728747 , -73,9514422416687 ) ; <br> <p> var mapOptions = { zoom : 13 , centro : NewYork , mapTypeId : " tabella di marcia " } ; <br> <p> map = new google.maps.Map ( document.getElementById ( " map " ) , mapOptions ) ; <br> <p> infowindow = new google . maps.InfoWindow ; <br> 8 <p> Chiamare una funzione che in modo asincrono recuperare i dati dal file PHP . Creare la funzione di callback che elaborerà i dati e tracciare i marker sulla mappa . Ad esempio, digitare : <br> <p> downloadPHPData ( " coordinates.php " , function ( data) { <br> <p> var xml = data.responseXML ; <br> <p> marker var = xml.documentElement . getElementsByTagName ( "marcatore" ) ; <br> <p> for (var i = 0; i < markers.length ; i + + ) { <br> città <p> var = marcatori [ i] getAttribute ( " città" ) . ; <br> <p> var punto = new google.maps.LatLng ( parseFloat ( marcatori [ i] getAttribute ( " lat " ) ) , parseFloat ( marcatori [ i] getAttribute ( " GNL ")) . . ) ; <br> <p> var html = città + "," + marcatori [ i] getAttribute ( " desc" ) ; <br> <p> var marcatore = new google.maps.Marker ( { map : . mappa , la posizione : punto , titolo : città } ) ; <br> <p> bindInfoWindow (marker , mappa , infowindow , html ) ; <br> <p> } <br> <p> }); } <br> <p> <br> < br > 9 <p> creare la funzione per recuperare i dati in modo asincrono e passare alla funzione di callback . Ad esempio, digitare : <br> <p> funzione downloadPHPData (URL , callback) { <br> <p> var richiesta = window.ActiveXObject ? new ActiveXObject ( " Microsoft.XMLHTTP " ) : nuovo XMLHttpRequest ; <br> <p> request.onreadystatechange = function () { <br> <p> se ( request.readyState == 4) { <br> richiesta <p> . onreadystatechange = DoNothing ; <br> <p> richiamata ( richiesta , request.status ) ; <br> <p> } <br> <p> } ; <br> <p> request.open ( 'GET' , URL , true); <br> <p> request.send ( null) ; } <br> <p> <br> <p> funzione DoNothing ( ) { } <br> <p> <br> 10 < p > Creare la funzione di pop -up nella finestra informativa in cui si fa clic su un marcatore . Ad esempio, digitare : <br> <p> funzione bindInfoWindow ( pennarello , mappa , infowindow , html ) { <br> <p> google.maps.event.addListener (marker , "click" , function () { <br> <p> infoWindow.setContent ( html ) ; <br> <p> infoWindow.open (mappa , marcatore); <br> <p> }); } <br> <p> <br> 11 < p > chiudere il tag script , chiudere il tag head , e creare il principale codice HTML per stabilire il " div " per la mappa e per lanciare la funzione di "creare" al caricamento della pagina . Ad esempio, digitare : <br> <p> < /script> <br> <p> < /head> <br> <p> <body onload="create()"> <br> < p > <div id="map" style="width:800px; height:800px"> < /div > <br> <p> < /body> <br> <p> < /html > <br> <br> <div class=ad2><script language='javascript' src='/ad/201310/4.js'></script></div> </div> </td> </tr> </table> <table width="95%" height="1" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DEE7EE"> <tr> <td></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="91%" height="52" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="51%"><p>Previous : <a class='LinkPrevArticle' href='/Programmazione/php-mysql-programming/92544.html' >Come leggere un file di caratteri animati con PHP </a></li></p></td> </tr> <tr> <td width="49%"> next : <a class='LinkNextArticle' href='/Programmazione/php-mysql-programming/92546.html' >Come accedere alle variabili di un altro file PHP </a></li></td> </tr> </table></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="770" height="246" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="375" height="246" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm"> Articoli Correlati </td> </tr> </table> <table width="95%" height="209" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="201"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92609.html" title="Come aggiornare le righe in MySQL " target="_self">Come aggiornare le righe in MySQL </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/93097.html" title="Come creare Conferma in PHP " target="_self">Come creare Conferma in PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92985.html" title="Come velocizzare le query su tabelle di grandi dimensioni estremamente MySQL " target="_self">Come velocizzare le query su tabelle di grandi dimensio…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91352.html" title="Un record PHP di tutte le query MySQL " target="_self">Un record PHP di tutte le query MySQL </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92990.html" title="Come creare un file di testo per MySQL " target="_self">Come creare un file di testo per MySQL </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91964.html" title="PHP Trucchi pulsante " target="_self">PHP Trucchi pulsante </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92377.html" title="Come riscrivere gli URL nei file PHP a un altro nome di dominio " target="_self">Come riscrivere gli URL nei file PHP a un altro nome di…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91821.html" title="Cookies Vs . Sessioni " target="_self">Cookies Vs . Sessioni </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92871.html" title="Come verificare PHP su un computer " target="_self">Come verificare PHP su un computer </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91408.html" title="Come Ricerca Mentre digitate su AJAX con PHP MySQL " target="_self">Come Ricerca Mentre digitate su AJAX con PHP MySQL </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> <td width="20" valign="top"></td> <td width="375" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm">Articoli in evidenza </td> </tr> </table> <table width="95%" height="207" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="199"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91381.html" title="PHP per rimuovere array multi - Duplicati " target="_self">PHP per rimuovere array multi - Duplicati </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87488.html" title="Codice esadecimale per Apostrophe " target="_self">Codice esadecimale per Apostrophe </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87073.html" title="Come Fractals grafico sulla TI -82 " target="_self">Come Fractals grafico sulla TI -82 </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/94829.html" title="Come utilizzare una classe di aree da escludere una Regione in VB.NET " target="_self">Come utilizzare una classe di aree da escludere una Reg…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/96466.html" title="Tutorial Visual Basic: Msgbox " target="_self">Tutorial Visual Basic: Msgbox </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/86724.html" title="Come unione di DNN e Xmod Cerca " target="_self">Come unione di DNN e Xmod Cerca </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91631.html" title="Come smettere di PHP URL popup in Firefox " target="_self">Come smettere di PHP URL popup in Firefox </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/java-programming/89893.html" title="Come convertire una raccolta di HashMap in Java " target="_self">Come convertire una raccolta di HashMap in Java </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/cc-programming/86218.html" title="Come utilizzare i puntatori in C + + " target="_self">Come utilizzare i puntatori in C + + </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/python-programming/93796.html" title="Python Ordina Funzione " target="_self">Python Ordina Funzione </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="980" height="8" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table border=0 cellSpacing=0 cellPadding=0 width=980 bgColor=#36506e height=90> <tr> <td class=bs height=90 align=middle>Copyright © Conoscenza Informatica http://it.wingwit.com <script language='javascript' src='/ad/201310/1.js'></script></td> </tr> </table> </div> </body> </html>