Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Passaggio variabili senza form

    Salve amici,
    sto cercando di adattare uno script di googles maps per prendere in automatico un indirizzo:

    <script type="text/javascript">
    //<![CDATA[

    var map = null;
    var geocoder = null;

    function load() {
    if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    geocoder = new GClientGeocoder();
    }
    }

    function showAddress(address) {
    if (geocoder) {
    geocoder.getLatLng(
    address,
    function(point) {
    if (!point) {
    alert(address + " not found");
    } else {
    map.setCenter(point, 13);
    var marker = new GMarker(point);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(address);
    }
    }
    );
    }
    }
    //]]>
    </script>

    questo è il codice javascript, che prende il valore da:

    <body onload="load()" onunload="GUnload()">
    <form action="#" onsubmit="showAddress(this.address.value); return false">



    <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" />
    <input type="submit" value="Go!" />
    </p>
    <div id="map" style="width: 500px; height: 300px"></div>
    </form>
    </body>

    Io però vorrei prendere il valore al caricamento della pagina da un database...

    come posso modificarlo?
    Digital XP - The new expression of digital art! - http://www.mimanchitu.it

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    potresti fare un'aggiunta alla funzione load
    codice:
    function load(indirizzo) {
    if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    geocoder = new GClientGeocoder();
    if(indirizzo!='')showAddress(indirizzo)
    }
    }
    e poi richiamarla così
    codice:
    <body onload="load('1600 Amphitheatre Pky, Mountain View, CA');" onunload="GUnload()">

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.