questo è il codice diciamo funzionante
questo è quello non funzionante<?php$conn = mysql_connect("localhost", "xxxx", "xxxx") or die(mysql_error());
mysql_select_db("mattina") or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title> Mappa</title>
<style type="text/css">
body { font: normal 15pt Helvetica, Arial; }
#map { width: 850px; height: 700px; border: 5px; padding: 5px; }
</style>
<script src="http://maps.google.com/maps/api/js?key=_____________&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/yellow.png",
new google.maps.Size(32, 32), new google.maps.Point(0, 0),
new google.maps.Point(16, 32));
var center = null;
var map = null;
var currentPopup;
var bounds = new google.maps.LatLngBounds();
function addMarker(lat, lng, info) {
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map
});
var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 300
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0, 0),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN
}
});
<?php
$query = mysql_query("SELECT cognome, nome, geo, lat, lng FROM moto")or die(mysql_error());
while($row = mysql_fetch_array($query))
{
$cognome= $row['cognome'];
$nome= $row['nome'];
$lat = $row['lat'];
$lng = $row['lng'];
$desc = $row['geo'];
echo("addMarker($lat, $lng, '$cognome.$nome');\n");
}
?>
center = bounds.getCenter();
map.fitBounds(bounds);
}
</script>
</head>
<body onload="initMap()" style="margin:5px; border:5px; padding:5px;"></body>
</html>
I dati vengono comunque cercati solo in lat e lng.<?php
$conn = mysql_connect("localhost", "xxxx", "xxxx") or die(mysql_error());
mysql_select_db("mattinale") or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title> Mappa</title>
<style type="text/css">
body { font: normal 15pt Helvetica, Arial; }
#map { width: 850px; height: 700px; border: 5px; padding: 5px; }
</style>
<script src="http://maps.google.com/maps/api/js?key=________________&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/yellow.png",
new google.maps.Size(32, 32), new google.maps.Point(0, 0),
new google.maps.Point(16, 32));
var center = null;
var map = null;
var currentPopup;
var bounds = new google.maps.LatLngBounds();
function addMarker(lat, lng, info) {
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map
});
var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 300
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0, 0),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN
}
});
<?php
$query = mysql_query("SELECT * FROM veicoli")or die(mysql_error());
while($row = mysql_fetch_array($query))
{
$cognome= $row['cognome'];
$nome= $row['nome'];
$lat = $row['lat'];
$lng = $row['lng'];
$desc = $row['luogo_furto'];
echo("addMarker($lat, $lng, '$cognome.$nome');\n");
}
?>
center = bounds.getCenter();
map.fitBounds(bounds);
}
</script>
</head>
<body onload="initMap()" style="margin:5px; border:5px; padding:5px;"></body>
</html>
schermata6.jpg schermata7.jpg