Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 18
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23

    generazione google maps dinamica

    ciao a tutti, sapete se c'è un modo veloce che mi consenta di incorporare una minimappa statica in una pagina di php?

    ho provato a copincollare il link fornito da google ad una qualsiasi mappa sostituendo latitudine e longitudine con le mie variabili estratte dal db ma mi rimanda alla ricerca di row[0] e row[1], a me servirebbe passargli queste due variabili per far visualizzare solo la minimappa, non navigabile ne cose speciali^^
    grazie!

  2. #2
    Codice PHP:
    <!DOCTYPE html>
    <html> 
    <head> 
      <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
      <title>Google Maps Multiple Markers</title> 
      <script src="http://maps.google.com/maps/api/js?sensor=false" 
              type="text/javascript"></script>
    </head> 
    <body>
      <div id="map" style="width: 500px; height: 400px;"></div>

      <script type="text/javascript">
     var locations = [
           ['Siamo Qui', <?php echo row[0];?><?php echo row[1];?>, 1]
        ];
           var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 10,
          center: new google.maps.LatLng(<?php echo row[0];?><?php echo row[1];?>),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        var infowindow = new google.maps.InfoWindow();

        var marker, i;

        for (i = 0; i < locations.length; i++) {  
          marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][1], locations[i][2]),
            map: map
          });

          google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
              infowindow.setContent(locations[i][0]);
              infowindow.open(map, marker);
            }
          })(marker, i));
        }
      </script>
    </body>
    </html>
    Spero di esserti stato di aiuto....
    Marko

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23
    ho provato ma non funziona perfettamente
    ti incollo lo stralcio di codice, io sono un novizio e non riesco a capire perchè non funziona, se mi potessi dare una mano mi saresti di grande aiuto!
    codice:
    $query2_res = pg_query($con, $query2); $row2 = pg_fetch_row($query2_res); $lat=$row2[0]; $long=$row2[1]; echo"<tr height=50 bgcolor='#E0F0B0'><td bgcolor='#E0F0B0' width=600>[b]"; echo "[b]".$row2[0].", ".$row2[1]; ?> <div id="map" style="width: 500px; height: 400px;"></div> <script type="text/javascript"> var locations = [ ['Siamo Qui', <?php echo $row2[0];?>, <?php echo $row2[1];?>, 1] ]; var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: new google.maps.LatLng(<?php echo $row2[0];?>, <?php echo $row2[1];?> ), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } </script> <?php echo "</td><td width=200> By:"; echo "<font color='black'><u>". $row[1]." ".$row[2]."</u>";
    tutto questo è incorporato in un while che esamina finchè ci sono entry e in un if che vede se il risultato è di tipo luogo, se di tipo luogo estrae latitudine e longitudine... il tuo codice mi mostra una mappa in uno dei tipi luogo mentre è blank negli altri, e il punto mostrato non è coincidente con le coordinate

  4. #4
    dai un occhiata qui...
    http://you.arenot.me/2010/06/29/goog...e-infowindows/

    dovresti solo inserire nel tuo ciclo le variabili di lat e long

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23
    codice:
    $query2_res = pg_query($con, $query2);
     $row2 = pg_fetch_row($query2_res);
     $lat=$row2[0];
     $long=$row2[1];
     echo"<tr height=50 bgcolor='#E0F0B0'>
    <td bgcolor='#E0F0B0' width=600>[b]"; 
    echo "[b]".$row2[0].", ".$row2[1]; ?> 
    <div id="map" style="width: 500px; height: 400px;"></div> 
    <script type="text/javascript">
     var locations = [ ['Siamo Qui', <?php echo $row2[0];?>, <?php echo $row2[1];?>, 1] ];
     var map = new google.maps.Map(document.getElementById('map'),
     { 
    zoom: 10, center: new google.maps.LatLng(<?php echo $row2[0];?>, <?php echo $row2[1];?> ),
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    });
     var infowindow = new google.maps.InfoWindow();
     var marker, i; 
    for (i = 0; i < locations.length; i++)
     {
     marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i)
     { 
    return function() { 
    infowindow.setContent(locations[i][0]); 
    infowindow.open(map, marker);
     }
     })
    (marker, i));
     } </script>
     <?php echo "</td><td width=200> By:"; 
    echo "<font color='black'><u>". $row[1]." ".$row[2]."</u>";

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23
    no, onestamente non ho capito nel link come fare

  7. #7
    Codice PHP:
     <script src="http://maps.google.com/maps?file=api&v=2&key=keyapitype="text/javascript"></script>
    <script type="text/javascript">
        //<![CDATA[
        function showMap()
        {
            if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));               
                map.addControl(new GSmallMapControl());                
                map.setCenter(new GLatLng(<?php echo row[0];?>,<?php echo row[1];?>), 10);            
          function createMarker(point, description) {
                  var marker = new GMarker(point);
                  GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(description);
                  });
                  return marker;
                }                        
                map.addOverlay(createMarker(new GLatLng(<?php echo row[0];?>,<?php echo row[1];?>), "Qui metti un testo"));      
          }
        }
     //]]>    
    </script>
    Devi solo cambiare la apikey...

  8. #8
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23
    con cosa cambio? (programmo da una settimana e mezzo, scusami davvero )

  9. #9
    1 Passo:
    https://www.google.com/url?sa=t&rct=...l9aIahIG0T4XBA

    vai qui è genera una api key per il tuo dominio
    2 Passo:
    Codice PHP:
    <?php
    $query2_res 
    pg_query($con$query2);
     
    $row2 pg_fetch_row($query2_res);
     
    $lat=$row2[0];
     
    $long=$row2[1];
    ?>
     <script src="http://maps.google.com/maps?file=api&v=2&key=keyapitype="text/javascript"></script> 
    <script type="text/javascript"> 
        //<![CDATA[ 
        function showMap() 
        { 
            if (GBrowserIsCompatible()) { 
                var map = new GMap2(document.getElementById("map"));                
                map.addControl(new GSmallMapControl());                 
                map.setCenter(new GLatLng(<?php echo $lat;?>,<?php echo $long;?> ), 10);             
          function createMarker(point, description) { 
                  var marker = new GMarker(point); 
                  GEvent.addListener(marker, "click", function() { 
                    marker.openInfoWindowHtml(description); 
                  }); 
                  return marker; 
                }                         
                map.addOverlay(createMarker(new GLatLng(<?php echo $lat;?>,<?php echo $long;?> ), "Qui metti un testo"));       
          } 
        } 
     //]]>     
    </script>   
     <body onload="showMap();" onunload="GUnload()">  
     <div id="content">
        <div id="map">Your browser doesn't support Google Maps or Javascript is turned off.</div>

    </div>
     </body>

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    23
    il problema è che sto lavorando in locale!
    (è un progetto universitario, non ci è richiesto di hostarlo)

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.