//classi
function map_obj(lat,long,html,icon,option)
{
this.lat = lat;
this.long = long;
this.html = html;
this.icon = icon;
this.option = option;
}
function driver_obj(nick,cellulare)
{
this.nick = nick;
this.cellulare = cellulare;
}
//classi
var global_map_icon_directory = "generale";
//if($("#icon_map_directory").length > 0)
//global_map_icon_directory = $("#icon_map_directory").html();
//questa variabile mi serve per capire se devo abilitare o meno la tab che permette di inviare gli sms dal web
//viene disabilitato per i clienti esterni che non hanno accesso al server SMS
var global_sms_from_map = 0;
var found_global_sms_from_map = 0;
//opt = change the behaviour of function in relationship to
//whic part of code calls it
//ie opt = ontop => marker on top
var infowindow_open = null;
function create_info_box(mappa,point,html,icona,targa,opt,driver)
{
//cerco solo una volta sul dom
if(found_global_sms_from_map == 1)
{
found_global_sms_from_map = 1;
if($("#sms_from_map").length > 0)
global_sms_from_map = $("#sms_from_map").html();
}
var marker;
var driver = typeof(driver) != 'undefined' ? driver : null;
var autista = "";
var cellulare_autista = "";
if(driver!=null)
{
autista = driver.nick;
cellulare_autista = driver.cellulare;
}
//tab per invio sms
var html_sms ="";
var intestazione_tab_sms = "";
if(global_sms_from_map == 1)
{
html_sms = '
';
intestazione_tab_sms = 'SMS';
}
//tab per invio sms
var extra_desc ="Posizione del veicolo ";
if(opt == null || opt =="")
{
marker = new MarkerWithLabel({
map:mappa,
position: point,
labelContent: targa,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75},
icon: icona});
marker.setZIndex(1);
}
else if(opt.indexOf("nomaplabel") !=-1) //lo usi per il marker manager in mainpage e per le zone
{
marker = new MarkerWithLabel({
position: point,
labelContent: targa,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75},
icon: icona});
extra_desc = "";
marker.setZIndex(1);
}
else if(opt.indexOf("ontop") !=-1)
{
marker = new MarkerWithLabel({
map:mappa,
position: point,
icon: icona
});
marker.setZIndex(999);
}
else if(opt.indexOf("paziente") !=-1)
{
marker = new MarkerWithLabel({
map:mappa,
position: point,
labelContent: targa,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75},
icon: icona});
extra_desc = "";
marker.setZIndex(1);
}
else if(opt.indexOf("nolabel") !=-1)
{
marker = new MarkerWithLabel({
map:mappa,
position: point,
icon: icona});
extra_desc = "";
marker.setZIndex(1);
}
else if(opt.indexOf("nomap") !=-1) //lo usi per il markermanager
{
marker = new MarkerWithLabel({
position: point,
icon: icona});
extra_desc = "";
marker.setZIndex(1);
}
else if(opt == "notabmap")
{
marker = new MarkerWithLabel({
map:mappa,
position: point,
labelContent: targa,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75},
icon: icona});
marker.setZIndex(1);
}
//html ="";
//intestazione_tab_sms="";
//html_sms="";
//style="height:330px" ;
var contentString = [
'',
'
',
'
',
html,
'
',
'
',
'
'+extra_desc+targa+'',
'
',
html_sms,
'
'
].join('');
infowindow = new google.maps.InfoWindow({
content: contentString
});
marker.infowindow = infowindow;
google.maps.event.addListener(marker, "click", function()
{
if(infowindow_open!=null) //chiudi la precedente aperta
infowindow_open.close();
infowindow_open = marker.infowindow;
marker.infowindow.open(mappa, marker);
google.maps.event.addListener( infowindow_open, 'domready', function(){
//creo la mappa piccola
var dMapDiv = $("#detailmap");
var myOptions = {
zoom: 15,
center: point,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//creo la mini mappa
var detailMap = new google.maps.Map(document.getElementById('detailmap'),myOptions);
//creo il marker
var sub_marker = new google.maps.Marker({
map: detailMap,
position: point
});
// $("#tabs_map").width("300"); //setto una altezza che non isnserisca lo scroll bar orizzontale
// $("#tabs_map").height("200"); //setto una altezza che non isnserisca lo scroll bar orizzontale
var $tabs = $("#tabs_map").tabs();
//metti il focus sulla prima tab
$tabs.tabs('select', 0);
if(opt!= null && opt == "notabmap")
$tabs.tabs('remove', 1);
//$("#tabs_map").parent().parent().width("400");
// $("#tabs_map").parent().parent().parent().height("4"); //setto una altezza che non isnserisca lo scroll bar verticale
});
//V2marker.zIndexProcess = onTop(marker);
//V2marker.openInfoWindowTabsHtml(infoTabs);
});
return marker;
}
function open_marker(ct)
{
for(var i = 0 ; i< global_array_marker.length;i++)
{
if(global_array_marker[i]!= null)
{
if(global_array_marker[i].ct == ct)
{
var position = global_array_marker[i].getPosition();
var b = new google.maps.LatLngBounds(position);
global_mapfleet.fitBounds(b);
google.maps.event.trigger(global_array_marker[i], 'click');
break;
}
}
}
}
function create_icon (img)
{
/*var icon = new GIcon();
icon.image = "/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/"+img;
icon.iconSize = new GSize(24, 39);
icon.iconAnchor = new GPoint(12,39);
icon.infoWindowAnchor = new GPoint(12, 5);*/
var icon = new google.maps.MarkerImage("/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/"+img, new
google.maps.Size(29,46));
//var icon = "/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/"+img;
return icon;
}
function select_icon_truck (direzione, digital_in,hardware,icona)
{
//nuova gestione delle icone ..
//l'icona viene salvata su inscodmerce per singolo veicolo e deve avere nome in questo formato
//d_ se l'icona fa parte di un set di 8 che contengono le direzioni
//e quindi se è camion avremo : d_camion_ne_on,d_camion_ne_off etc..
// se l'icona fa parte di un set di 2 quindi solo acceso spento
//console.log(icona);
if(typeof icona == "Undefined")
{
icona = "d_camion";
}
var result = icona;
if(icona.indexOf("d_") == 0)
{
if (direzione >=0 && direzione <=90)
result = result +"_ne";
else if (direzione >90 && direzione <=180)
result = result +"_se";
else if (direzione >180 && direzione <=270)
result = result +"_sw";
else if (direzione >270 && direzione <=360)
result = result +"_nw";
}
if (digital_in >= 8)
{
result = result+"_on";
}
else
{
result = result+"_off";
}
result = result+".png";
//console.log(result);
return create_icon(result);
}
function hide_marker(ct)
{
for(var i = 0 ; i< global_array_marker.length;i++)
{
if(global_array_marker[i]!= null)
{
if(global_array_marker[i].ct == ct)
{
if (!global_array_marker[i].getMap())
{
global_array_marker[i].setMap(global_mapfleet);
}
else
{
global_array_marker[i].setMap(null);
global_array_marker[i].infowindow.close();
}
break;
}
}
}
}
function initialize(dom_element)
{
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(45.23872577078619, 11.762773990631104),
scaleControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true
}
var mp = new google.maps.Map(document.getElementById(dom_element),myOptions);
mp.setTilt(45); //imposta la label a 45 gradi , attualmente solo per venezia
// mp.addMapType(G_SATELLITE_3D_MAP);
bounds = new google.maps.LatLngBounds();
return mp;
}
function initialize_simple(dom_element)
{
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(45.23872577078619, 11.762773990631104),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var mp = new google.maps.Map(document.getElementById(dom_element),myOptions);
bounds = new google.maps.LatLngBounds();
return mp;
}
//V2 forse nelle V3 non serve anche perchè comunque la chiamata GEvent è errata
/*function remove_event_for_marker (marker)
{
GEvent.clearListeners(marker,"click");
GEvent.clearListeners(marker, "infowindowopen");
}*/
/* funzione utilizzate dalla generalmap (mainpage_google.js) per disegnare, uno alla volta, un array di punti */
function draw_point_map (mappa,dat,tipo,indice)
{
if (dat.longitudine!="" && dat.longitudine!=null && dat.latitudine!="" && dat.latitudine!=null && dat.latitudine!=0)
{
var point = new google.maps.LatLng(dat.latitudine,dat.longitudine);
//var point_label = new google.maps.LatLng(point.lat(),(point.lng()/2));
bounds.extend(point);
var html = "";
html+= "Targa: "+dat.name+"
";
html+= "Data/ora: "+dat.datadb+"
";
if (dat.indirizzo != "NOT GEOCODING")
{
html+= "Indirizzo (Zona): "+dat.indirizzo+"
";
if(dat.indirizzo_zone!=null && dat.indirizzo_zone!="" )
html+=" ("+dat.indirizzo_zone+")
";
}
html+= "Velocita: "+dat.velocita+" Km/h
";
html+= "Batteria: "+dat.batteria+" %
";
// Crea l'icona personalizzata
var icona = select_icon_truck(dat.direzione, dat.digital_in,dat.hardware, dat.icona);
//var marker = new google.maps.Marker(point,icona);
dat.html = html;
//V2 la pulizia ora con V£ la faccio prima
/*
//eseguo la pulizia di eventuali eventMarker precedenti
if (global_array_marker[indice] != null)
{
//remove_event_for_marker(global_array_marker[indice]);
//V3 global_mgr_fleet.removeMarker(global_array_marker[indice]);
}
*/
var driver = new driver_obj(dat.nome_autista,dat.cellulare);
dat.marker = create_info_box(mappa,point,html,icona,dat.name,"nomaplabel",driver);
//V3 global_mgr_fleet.addMarker(dat.marker,3);
//console.log(dat);
}
else
{
//eseguo la pulizia di eventuali eventMarker precedenti
if (global_array_marker[indice] != null)
{
// remove_event_for_marker(global_array_marker[indice]);
//V3 global_mgr_fleet.removeMarker(global_array_marker[indice]);
dat.marker = null;
dat.html = null;
dat.label = null;
}
}
if(dat.marker!= null)
{
var zoom = mappa.getZoom();
if(zoom > 10) // gestisci se vuoi o meno la label
dat.marker.labelVisible = true;
else
dat.marker.labelVisible = false;
}
return dat;
}
/* funzione utilizzate dalla mapvehicle per disegnare un singolo punto sulla mappa */
function draw_single_point (mappa,json,opt)
{
if (json.result != 'empty')
{
if(json.dati[0].longitudine!="" && json.dati[0].longitudine!=null && json.dati[0].latitudine!="" && json.dati[0].latitudine!=null && json.dati[0].latitudine!=0)
{
var point = new google.maps.LatLng(json.dati[0].latitudine,json.dati[0].longitudine);
bounds.extend(point);
var html = "";
var option ="";
if(json.dati[0].name!= null)
html+= "Targa: "+json.dati[0].name+"
";
if(json.dati[0].name_rubrica!= null)
{
html+= "Nome: "+json.dati[0].name_rubrica+"
";
option = "paziente";
}
if( typeof(opt) != "undefined")
option = opt;
if(json.dati[0].ora != null)
html+= "Ora: "+json.dati[0].ora+"
";
if (json.dati[0].indirizzo != "")
html+= "Indirizzo (zona): "+json.dati[0].indirizzo+"
";
if( json.dati[0].velocita!= null)
html+= "Velocità: "+json.dati[0].velocita+" Km/h
";
/* var label = new ELabel(point, json.dati[0].targa, "style1", new GSize(-9,18), 75);
mappa.addOverlay(label); */
var label_txt ="";
if(json.dati[0].name!= null)
label_txt = json.dati[0].name;
if(json.dati[0].name_rubrica!= null)
label_txt = json.dati[0].name_rubrica;
var icona = select_icon_truck(json.dati[0].direzione, json.dati[0].digital_in,json.dati[0].hardware,json.dati[0].icona );
json.dati[0].marker = create_info_box(mappa,point,html,icona,label_txt,option);
json.dati[0].html = html;
}
//mappa.setCenter(bounds.getCenter());V2
//mappa.setZoom(mappa.getBoundsZoomLevel(bounds));V2
mappa.fitBounds(bounds);
//--------------------------------------------------------------
//imposta il livello di zoom dopp aver fatto il bound sul punto
var zoomListner = google.maps.event.addListener(mappa, 'zoom_changed', function() {
google.maps.event.removeListener(zoomListner);
if (this.getZoom() > 16) // Change max/min zoom here
this.setZoom(16);
});
//--------------------------------------------------------------
//mappa.setZoom(16);
return json;
}
}
//json : lat, long
function draw_simple_point(mappa,lat,long)
{
var point = new google.maps.LatLng(lat,long);
bounds.extend(point);
var marker = new google.maps.Marker({
map:mappa,
position: point
});
mappa.fitBounds(bounds);
return point;
}
//funzione per disegnare un punto sulla mappa, con il baloon
//a seconda di quello che passi nell'objhai varie possibilità
function draw_single_point_2(mappa,obj)
{
//coma minimo devi avere la t e long
var point = new google.maps.LatLng(obj.lat,obj.long);
bounds.extend(point);
//quello che vuoi scrivere dentro il ballon
var html ="";
if(obj.html!= null)
html = obj.html;
var icon = "";
if(obj.icon!= null)
icon =create_icon(obj.icon);
//console.log(icon);
var label_txt = "";
if(obj.label_txt!= null)
label_txt = obj.label_txt;
//servono per le varie opzioni di disegno del marker, fare riferimento a create_info_box
var option = "";
if(obj.option!= null)
option = obj.option;
var marker = create_info_box(mappa,point,html,icon,label_txt,option);
return marker;
}
//passo la mappa e il json con i dati per disegnare anche i ballon
global_array_marker_pazienti = null;
function draw_point_paziente(mappa,json)
{
if(global_array_marker_pazienti!= null)
{
//console.log("avaa");
for(var x = 0; x 0) //non è al piano terra
{
if(json.data[i].ascensore == 0) //no c'è ascensore
type_icon = "red";
}
}
icon =type_icon+".png";
var html = ""+label_txt+""+"
";
html += "Indirizzo:"+json.data[i].indirizzo_rubrica+"
";
html += "Entrata: "+entrata+"
";
html += "Uscita: "+uscita+"
";
html += "
";
html += "Ascensore: "+translate_status(json.data[i].ascensore,"")+"
";
html += "Scale: "+translate_status(json.data[i].scale,"scale")+"
";
html += "Accompagnato: "+translate_status(json.data[i].accompagnato,"")+"
";
html += "Carrozzina: "+translate_status(json.data[i].carrozzina,"carrozzina")+"
";
html += "Peso: "+translate_status(json.data[i].obeso,"peso")+"
";
html += "Note: "+json.data[i].note_rubrica;
obj_map =new map_obj(json.data[i].latitudine_rubrica,json.data[i].longitudine_rubrica,html,icon,"paziente");
obj_map.label_txt = label_txt;
var marker = draw_single_point_2(mappa,obj_map);
global_array_marker_pazienti[index] = marker;
index++;
}
}
mappa.fitBounds(bounds);
}
function my_point(point,info,name,distance)
{
this.point = point;
this.info = info;
this.name = name;
this.distance = distance;
}
//map :object map
//data to draw
var draw_title = true; //add the name of veihcle
function draw_route(map,json,global_marker_manager_fleet)
{
var result = null;
if (json != 'empty')
{
var center_latitudine;
var center_longitudine;
var mpoints = new Array(); //here we save mypoints (mp)
var mp = null; //here we have info about point and point itself
var points = new Array(); //here I have the point itself ,gpoint
var first_point = true;
var j = 0 ; //index for the good point
result = new Array();
var enable_filter = 0;
var distance = 0 ; //distance beetween two points
//disegnamo punti ogni 1 km
var offset = 500;
//console.log(json.length);
if(json.length > 800)
{
enable_filter = 1;
}
var last_temposec = 0;
for (var i = 0; i < json.length; i++) //json.length
{
if(draw_title == true && i == 0)
{
if($("#title_maproute").length >0)
{
var t = $("#title_maproute").html();
$("#title_maproute").html(t+" "+json[i].idvet);
}
draw_title = false;
}
//console.log("json "+json.length+" "+ json[i].dettagli[0]);
//console.log("json "+json.length+" "+ json[i].dettagli[0]);
//console.log(global_json[i].longitudine +" "+global_json[i].latitudine);
//mi serve un controllo per non disegnare punti troppo vicini.
if(json[i].plongitudine!="" && json[i].plongitudine!=0 && json[i].platitudine!="" && json[i].platitudine!=null && json[i].platitudine!=0 && json[i].gps_valid == 1)
{
if(enable_filter && i>=1) //se i = 0 i -1 va in errore ;)
{
//distance = distance +parseInt((parseInt(json[i].distance) - parseInt(json[i-1].distance)));
diff = parseInt(json[i].temposec) - parseInt(last_temposec);
diff = parseInt(diff )
if(diff < 30) //mostra punti ogni 30 sec
{
continue;
}
else
{
last_temposec = json[i].temposec;
}
/*
if(parseInt(distance) <= parseInt(offset) )
{
//console.log(distance);
continue;
}
else
{ //console.log(distance);
distance = 0 ;
}
*/
}
var point = new google.maps.LatLng(json[i].platitudine,json[i].plongitudine);
result[i] = point;
bounds.extend(point);
var html = "";
html+=""+(j+1)+"/"+(json.length)+"
";
html+= "Data/ora: "+json[i].tempo+"
";
var indirizzo = json[i].indirizzo;
html+= "Indirizzo (Zona): "+indirizzo+"
";
if(json[i].indirizzo_zone!=null)
html+=" ("+json[i].indirizzo_zone+")
";
html+= "Velocita: "+json[i].velocity+" Km/h
";
/*html+= "Batteria: "+json[i].batteria+"
"; */
mp = new my_point(point,html,json[i].idvet,json[i].dist);
mpoints[j] = mp;
points[j] = point;
//var marker = create_info_box(map,point,html);
if(first_point) //start icon, first point valid
{
var start_icon_path = "http://www.google.com/mapfiles/dd-start.png";
marker = create_info_box(map,point,html,start_icon_path,json[i].idvet,"ontop");
first_point = false;
}
if(i==json.length-1) //end
{
var end_icon_path = "http://www.google.com/mapfiles/dd-end.png";
marker = create_info_box(map,point,html,end_icon_path,json[i].idvet,"ontop");
}
j++;
}
}
//console.log(j);
var line = new google.maps.Polyline({
path: points,
strokeColor: "#3366FF",
strokeOpacity: 1.0,
strokeWeight: 2
});
line.setMap(map);
arrowHead(mpoints,map);
midArrows(mpoints,map,global_marker_manager_fleet,enable_filter);
//mgr.refresh();V2
global_marker_manager_fleet.refresh();
//map.setCenter(bounds.getCenter());
map.fitBounds(bounds);
google.maps.event.addListener(map, "zoom_changed", function() {
global_marker_manager_fleet.refresh();
});
}
else
{
//global_map.setCenter(new google.maps.LatLng(global_json[global_json.length-1].platitudine,global_json[global_json.length-1].plongitudine), 10);
//mappa.setCenter(new google.maps.LatLng(global_json[0].latitudine,global_json[0].longitudine),5);
}
return result;
}
//utility functions to change color for a zone
//color for the zones
var global_start_color = "336600";
var global_last_color = "336600";
function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);}
function padLeft(str, pad, count)
{
while(str.lengthPunto di partenza";
marker = create_info_box(map,point,html,image,"Inizio","");
markers_array.push(marker);
}
else if(json.data[i][j].tipo == "E")
{
image ="/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/numbered_markers/marker.png";
html = "Nome zona: "+json.details[i][0].name;
html+= "
Punto di arrivo";
marker = create_info_box(map,point,html,image,"Fine","");
markers_array.push(marker);
}
}
}
global_last_color = increase_color(global_last_color);
polyline = new google.maps.Polyline({
path: points,
strokeColor: '#'+global_last_color,
strokeOpacity: 1.0,
strokeWeight: 2
});
polyline.setMap(map);
//salva le polyline
polyline_array[i] = polyline;
//V2polyline = polylineEncoder.dpEncodeToGPolyline(points, '#'+global_last_color, 4, 0.7);
//v2map.addOverlay(polyline);
map.fitBounds(bounds);
}
}
//draw a collection zone
//need this function when you have to comapare a dayly trip with a collection zone
//input json = {"status":"ok","operation":"get_zone_details","name_zone":"lusevera","rows":"386","data":[{"trackid"
//:"18225909","fk_id_zone":"128957503650000000","tipo":"S","platitudine":"46.215054","plongitudine":"13
//.219834","indirizzo":null,"tempo":"2009-08-26 10:52:46","distance":"0","direction":"0.00","velocity"
//:"0"}]}
var markers_array = new Array();
function draw_collection_zone(map,json)
{
var polyline;
global_points_zone = new Array(); //empty the array
if(markers_array!= null && markers_array !="")
{
for(var i= 0;iPunto di partenza";
marker = create_info_box(map,point,html,image,"Inizio","");
markers_array.push(marker);
}
else if(json.data[j].tipo == "E")
{
var image = "";
image ="/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/numbered_markers_green/marker01.png";
var html = "Nome zona: "+json.name_zone;
html+= "
Punto di arrivo";
marker = create_info_box(map,point,html,image,"Fine","");
markers_array.push(marker);
}
else if(json.data[j].tipo == "M")
{
marker_index++;
var image = "";
image ="/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/numbered_markers_green/marker"+marker_index+".png";
var html = "Nome zona: "+json.name_zone;
marker = create_info_box(map,point,html,image,"","nolabel");
markers_array.push(marker);
}
}
}
polyline = new google.maps.Polyline({
path: global_points_zone,
strokeColor: '#00FF00',
strokeOpacity: 1.0,
strokeWeight: 2
});
polyline.setMap(map);
global_polyline_collection = polyline;
//map.addOverlay(new GPolyline(points));
}
function onTop(marker) {
return GOverlay.getZIndex(marker.getPoint().lat()) + 1000000;
}
function draw_rest(map,json)
{
if (json != 'empty')
{
if(json.soste!= null && json.soste!="")
{
if(json.soste.stopping!=null && json.soste.stopping!="")
{
for(i = 0 ; i< json.soste.stopping.length; i++)
{
if(json.soste.stopping[i].latitudine!=0 && json.soste.stopping[i].latitudine!="")
{
if(json.soste.stopping[i].longitudine!=0 && json.soste.stopping[i].longitudine!="")
{
var point = new google.maps.LatLng(json.soste.stopping[i].latitudine,json.soste.stopping[i].longitudine);
/* var marker = new google.maps.Marker(point); old*/
var html = "Sosta
";
html += "Inizio: "+json.soste.stopping[i].iniziososta+"
";
html += "Fine: "+json.soste.stopping[i].finesosta+"
";
var Hours = Math.floor(parseFloat(json.soste.stopping[i].duratasosta)/60);
var Minutes = parseFloat(json.soste.stopping[i].duratasosta)%60;
var rest_duration = Hours + ":" + Math.round(Minutes);
html += "Durata: "+rest_duration+" (HH:mm)
";
Hours = Math.floor(parseFloat(json.soste.stopping[i].duratasostaDIGIN8)/60);
Minutes = parseFloat(json.soste.stopping[i].duratasostaDIGIN8)%60;
rest_duration = Hours + ":" + Math.round(Minutes);
html += "Motore spento: "+rest_duration+" (HH:mm)
";
/* add_info_box(marker,html);
map.addOverlay(marker); old*/
var path_to_icon ="/../../../ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/rest.png";
var marker = create_info_box(map,point,html,path_to_icon,"Sosta","ontop");
}
}
}
}
}
}
}
// === A function to create the arrow head at the end of the polyline ===
function arrowHead(points,map)
{
// === The basis of the arrow icon information ===
/*var arrowIcon = new GIcon();
arrowIcon.iconSize = new GSize(24,24);
arrowIcon.shadowSize = new GSize(1,1);
arrowIcon.iconAnchor = new GPoint(12,12);
arrowIcon.infoWindowAnchor = new GPoint(0,0);*/
// == obtain the bearing between the last two points
var p1=points[points.length-1].point;
var p2=points[points.length-2].point;
var dir = bearing(p2,p1);
// == round it to a multiple of 3 and cast out 120s
var dir = Math.round(dir/3) * 3;
while (dir >= 120) {dir -= 120;}
// == use the corresponding triangle marker
var icon_path = "http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";
// map.addOverlay(new google.maps.Marker(p1, arrowIcon));
/* var marker = new google.maps.Marker(p1, arrowIcon);
add_info_box(marker,points[points.length-1].info); old*/
var marker = create_info_box(map,points[points.length-1].point,points[points.length-1].info,icon_path,points[points.length-1].name,"");
}
/** Convert radians to numeric (signed) degrees */
if (typeof(String.prototype.toDeg) === "undefined") {
Number.prototype.toDeg = function() {
return this * 180 / Math.PI;
}
}
function bearing( from, to ) {
// === Returns the bearing in degrees between two points. ===
// North = 0, East = 90, South = 180, West = 270.
var degreesPerRadian = 180.0 / Math.PI;
var lat1 = from.lat();
var long1 = from.lng();
var lat2 = to.lat();
var long2 = to.lng();
var dLon = long2-long1;
var y = Math.sin(dLon) * Math.cos(lat2);
var x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
var brng = Math.atan2(y, x);
if ( brng < 0.0 )
brng += Math.PI * 2.0;
brng = brng.toDeg();
return brng;
}
// === A function to put arrow heads at intermediate points
function midArrows(points,map,mgr,enable_filter) {
// === The basis of the arrow icon information ===
/*
var arrowIcon = new GIcon();
arrowIcon.iconSize = new GSize(24,24);
arrowIcon.shadowSize = new GSize(1,1);
arrowIcon.iconAnchor = new GPoint(12,12);
arrowIcon.infoWindowAnchor = new GPoint(0,0);
*/
var j = 0;
var marker_index = 1;
var distance = 0 ; //distance beetween two points
var offset = 6000;
if(points.length >=1)
{
offset = Math.round(parseInt(points[points.length-1].distance)/100);
}
//console.log("off "+offset);
for (var i=1; i < points.length-1; i++) {
var p1=points[i-1].point;
var p2=points[i+1].point;
var dir = bearing(p1,p2);
//console.log(points[i].distance +" "+i);
distance = distance +parseInt( (parseInt(points[i].distance) - parseInt(points[i-1].distance)));
// console.log( points[i].distance +"-" +points[i-1].distance+" = " + distance);
// == round it to a multiple of 3 and cast out 120s
var dir = Math.round(dir/3) * 3;
while (dir >= 120) {dir -= 120;}
// == use the corresponding triangle marker
// console.log("http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png");
/*
arrowIcon = new GIcon();
arrowIcon.iconSize = new GSize(24,24);
arrowIcon.shadowSize = new GSize(1,1);
arrowIcon.iconAnchor = new GPoint(12,12);
arrowIcon.infoWindowAnchor = new GPoint(0,0);
arrowIcon.image = "http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";
*/
var icon_arrow = new google.maps.MarkerImage("http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png", new
google.maps.Size(24, 24));
j++
var marker;
if(parseInt(distance) >= parseInt(offset) )
{
/*
arrowIcon = new GIcon();
arrowIcon.iconSize = new GSize(20,34);
arrowIcon.shadowSize = new GSize(1,1);
arrowIcon.iconAnchor = new GPoint(10,34);
arrowIcon.infoWindowAnchor = new GPoint(0,0);
arrowIcon.image ="/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/numbered_markers/marker"+marker_index+".png";
*/
var icon_path = new google.maps.MarkerImage("/ctwebinterface/imgmyfleet/icons/icon_map/"+global_map_icon_directory+"/numbered_markers/marker"+marker_index+".png", new
google.maps.Size(20, 34));
// console.log (distance + "j "+j);
marker = create_info_box(map,points[i].point,points[i].info,icon_path,points[i].name,"nomap");
marker_index++;
//console.log(marker_index);
mgr.addMarker(marker,3); //show it V2
//j=0;
distance = 0 ;
}
else
{
if(!enable_filter)
{
marker = create_info_box(map,points[i].point,points[i].info,icon_arrow,points[i].name,"nomap");
mgr.addMarker(marker,12); //show it only at high zoom level V"
}
//console.log(distance +" j in "+j);
}
//map.addOverlay(marker);
}
}
//load zone
//RETURN: a json which contains the list of the zones
function load_zone(map,path,opt)
{
var result ;
/* $.ajax({
type:'GET',
url:'../control_myfleet/control_zone_ajax.php',
data:{load:load,type:all},
error: function(xhr){alert(xhr);},
complete: function(xhr){alert(xhr);},
success: function(data){alert(data);}
}); */
var url_to_zone = '../control_myfleet/control_zone_ajax.php';
if(path!=null)
url_to_zone = path;
var show_modal = false;
if(opt!=null)
{
if(opt.search('modal_show'))
{
show_modal = true;
}
}
$.ajax({
type:'GET',
url:url_to_zone,
data:{load:'1',type:'all'},
error: function(xhr){complete_zone(show_modal);},
beforeSend: function(xhr){before_load_zone(show_modal);},
complete: function(xhr){complete_zone(show_modal);},
success: function(data){draw_zones(map,data,opt);}
});
}
function before_load_zone(s)
{
if(s==true)
{
simple_modal_loading(" Attendere","Aggiornamento in corso...");
}
}
function complete_zone(s)
{
if(s==true)
{
if($.modal!=null)
$.modal.close();
}
}
//this function draw the zone you have in the table
//control_zones, this markers are indipendent from the one which rapresents the trucks, and they are manaeed by a marker manager
//creo la classe per le icone
function myIcon(_path,_id)
{
this.image = _path;
this.id = _id;
}
var markers_zone = new Array();
function draw_zones(mappa,json,opt)
{
//create the marker manager
if(mappa==null)
return; //if you don't have any assets in the map the map wasn't initialized so the object map is null
var icon_array = Array();
if( typeof(json.icon) != "undefined" && json.icon!="")
{
for(var i=0;iNome: "+json.dati[i].name+"
";
html+= "Codice zona: "+json.dati[i].desc_zone+"
";
html+= "
Latitudine: "+json.dati[i].latitudine+"
";
html+= "Longitudine: "+json.dati[i].longitudine+"
";
icona ="";
if(json.dati[i].id_icon!="")
{
for(var m = 0 ;m< icon_array.length;m++)
{
if(icon_array[m].id == json.dati[i].id_icon)
{
icona = icon_array[m];
}
}
}
if( json.dati[i].desc_zone.length > 0)
markers_zone[i] = create_info_box(mappa,point,html,icona.image,json.dati[i].desc_zone,"nomaplabel");
else
markers_zone[i] = create_info_box(mappa,point,html,icona.image,json.dati[i].desc_zone,"nomap");
if(zoom > 10) // gestisci se vuoi o meno la label
markers_zone[i].labelVisible = true;
else
markers_zone[i].labelVisible = false;
global_mgr_zone.addMarker(markers_zone[i],0,0);
}
//attacco un evento al cambio di zoom in modo da gestire la scomaprsa delle label dei marker delle zone
google.maps.event.addListener(mappa, "zoom_changed", function() {
var zoom =mappa.getZoom();
if(zoom > 10 )
{
for(var i = 0 ; i