<?
include("conexion.php");
//51,7
$query="
SELECT `latitud`,`longitud`
FROM `records`
WHERE `localizadorid` = 7
and contacto=1
and fecha='2015-02-08'
order by fecha desc, hora desc
";
$result = mysql_query($query) or die(mysql_error());
$ruta="";
$anterior="";
$inicio="";
while($row = mysql_fetch_array($result))
{
if ($anterior=="")
{
$anterior=$row['latitud']. ",". $row['longitud'];
$ruta="new google.maps.LatLng(".$row['latitud']. ",". $row['longitud']."),";
$inicio=$row['latitud']. ",". $row['longitud'];
}
else
{
if ($anterior!=($row['latitud']. ",". $row['longitud']))
{
$anterior=$row['latitud']. ",". $row['longitud'];
$ruta.="new google.maps.LatLng(".$row['latitud']. ",". $row['longitud']."),";
}
}
}
//*** quita la ultima coma
$ruta = substr($ruta, 0, strlen($ruta)-1);
/*
<img src="http://maps.googleapis.com/maps/api/staticmap?center=38.3614432,-0.4982803&zoom=<?echo $zoom;?>&size=640x640&maptype=roadmap&markers=color:blue|Clabel:A|38.3614432,-0.4982803|color:blue|Clabel:B|38.4614432,-0.4982803&sensor=false"/>
<br>
<img src="http://maps.googleapis.com/maps/api/staticmap?format=jpg¢er=<?echo $y;?>,<?echo $x;?>&zoom=<?echo $zoom;?>&size=640x640&sensor=false&path=color:0x0000ffff|weight:5<?echo $aux;?>"/>
*/
?>
<!DOCTYPE html><html><head><title>MGFLOTAS</title>
<meta name='viewport' content='initial-scale=1.0, user-scalable=no'>
<meta charset='utf-8'>
<style>
#map_canvas{height: 500px; width: 500px; margin: 0px; padding: 0px}
</style>
<script src='https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'>
</script>
<script>
var ruta = [<?echo $ruta;?>];
function inicializar()
{
geocoder = new google.maps.Geocoder();
var myOptions = {
center: new google.maps.LatLng(<?echo $inicio;?>),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDoubleClickZoom: true,
draggable: false,
scrollwheel: false,
disableDefaultUI: true // quita la barra de ZOOM del mapa
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var lineas = new google.maps.Polyline({path: ruta,map: map,strokeColor: '#000000',strokeWeight: 4,strokeOpacity: 0.9,clickable: false});
fin = new google.maps.Marker({position: new google.maps.LatLng(<?echo $inicio;?>),map: map});
//****** centrar en el mapa
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < ruta.length; i++) {
bounds.extend(ruta[i]);
}
map.fitBounds(bounds);
}
</script>
<body onload='inicializar()'>
<div id='map_canvas'>
</body>
.
domingo, 8 de febrero de 2015
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario