← Back
Editing: gmap_ed.php
<?php #______________________________________________________________________# ### made with SmaDIB: Smart Database Interface Builder 0.4.0 ### ### by Smartmedia 2000 http://www.smartmedia2000.it/ ### ### info email: smadib@smartmedia2000.it ### ### released under GPL license http://www.gnu.org/licenses/gpl.txt ### ###___###___###___###___###____###____###____###___###___###___###___### require_once ("../funct.php"); require_once ("sess.php"); require_once ("conn.php"); $ptitolo = "Google map"; $table = "struttura"; $gmap = "y"; $jScript = "initialize(); showLocation();\" onunload=\"GUnload()"; require_once ("testacoda.php"); $query = new doQuery(); if ($az == "up") $query->update ($_POST, $novuoto); $row = $query->freeQuery ("SELECT `id`, `coord_gmap`, `indirizzo`, `cap`, `comune`, `provincia` FROM `$table` WHERE `id_utente` = $id_utente", 0); $row = $row[0]; $indirizzo = $row->indirizzo." ".$row->cap." ".$row->comune." ".$row->provincia." Italia"; if ($row->coord_gmap == "") { $indir_iniz = $indirizzo; $coord_gmap = "(42.7838, 11.111)"; } else { $indir_iniz = $row->coord_gmap; $coord_gmap = $row->coord_gmap; } $zoom = 15; echo $testa; ?> <script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyABd3zQMkeL8PG2AmwEXBWEDlKjxAtZpuw" type="text/javascript"></script> <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById('map_canvas')); var center = new GLatLng<?php echo $coord_gmap; ?>; map.setCenter(center, <?php echo $zoom; ?>); var mapTypeControl = new GMapTypeControl(); var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10)); var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10)); map.addControl(mapTypeControl, topRight); GEvent.addListener(map, 'dblclick', function() { map.removeControl(mapTypeControl); map.addControl(new GMapTypeControl(), bottomRight); }); map.addControl(new GSmallMapControl()); var marker = new GMarker(center, {draggable: true}); var coords = marker.getLatLng(); input_lat = 0; input_lon = 0; GEvent.addListener(marker, 'dragstart', function() { map.closeInfoWindow(); }); GEvent.addListener(marker, 'dragend', function() { coords = marker.getLatLng(); document.form1.coord_gmap.value = coords; document.getElementById('coord').lastChild.nodeValue = coords; //marker.openInfoWindowHtml('coords '+coords); }); map.addOverlay(marker); geocoder = new GClientGeocoder(); // posiziona il marker sui punti codificati da google } } function addAddressToMap(response) { map.clearOverlays(); if (!response || response.Status.code != 200) { alert ("Impossibile trovare l'indirizzo specificato, trascina il marker per posizionarti. Usa lo zoom per trovare la via"); var point = new GLatLng(42.76, 11.1136); marker = new GMarker(point, {draggable: true}); map.addOverlay(marker); GEvent.addListener(marker,"dragend", function() { var latlng2 = marker.getLatLng(); document.form1.coord_gmap.value = latlng2; document.getElementById('coord').lastChild.nodeValue = latlng2; map.setCenter(latlng2); }); map.setCenter(point, <?php echo $zoom; ?>); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); document.form1.coord_gmap.value = '('+ place.Point.coordinates[1] +', '+ place.Point.coordinates[0] +')'; document.getElementById('coord').lastChild.nodeValue = '('+ place.Point.coordinates[1] +', '+ place.Point.coordinates[0] +')'; marker = new GMarker(point, {draggable: true}); map.addOverlay(marker); GEvent.addListener(marker,"dragend", function() { var latlng2 = marker.getLatLng(); input_lat.value = latlng2.lat(); input_lon.value = latlng2.lng(); document.form1.coord_gmap.value = latlng2; document.getElementById('coord').lastChild.nodeValue = latlng2; map.setCenter(latlng2); }); map.setCenter(point); // marker.openInfoWindowHtml(place.address + '<br>' + '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode); } } function showLocation() { var indirizzo = document.getElementById('indirizzo'); var address = indirizzo.value; geocoder.getLocations(address, addAddressToMap); } </script> <h2><div align="center"><?php echo $ptitolo; ?></div></h2> <div align="center"> <div id="map_canvas" style="width: 640px; height: 480px"></div> <p>Indirizzo iniziale / coordinate salvate<br /> <input type="text" name="indirizzo" id="indirizzo" size="50" value="<?php echo $indir_iniz; ?>" /><br /> <input type="button" value="copia indirizzo struttura" onclick="javascript:document.getElementById('indirizzo').value='<?php echo addslashes ($indirizzo); ?>';" /> <input type="button" value="cerca" onclick="javascript:showLocation();" /> </p><div align="center"> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> coordinate punto <span id="coord"><?php echo $coord_gmap; ?></span><br /> <input type="hidden" name="coord_gmap" value="<?php echo $coord_gmap; ?>" /> <p><input type="submit" value="conferma posizione"></p> <input type="hidden" name="id" value="<?php echo $row->id; ?>" /> <input type="hidden" name="az" value="up" /> </table></form> </div> <?php echo $coda; ?>
Save File
Cancel