Pessoal,
Tenho esse foreach e queria fazer uma validação nele, verificar se o registro anterior é diferente do pt, se for grava novo senão pula:
function calcRoute() {
var myTrip=[];
var bounds = new google.maps.LatLngBounds();
<c:forEach var="listaCoord" varStatus="posicao" items="${listaCoord}">
var dt = '${listaCoord.dtSistema}';
var cod = '${listaCoord.codDaf}';
var lat = '${listaCoord.idLatitude}';
var lng = '${listaCoord.idLongitude}';
var bt = '${listaCoord.bateria}';
var pt = new google.maps.LatLng(lat, lng);
myTrip.push(pt);
bounds.extend(pt);
/*ERRO AQUI - Syntax error on token "_$tag______", ; expected*/
<c:choose>
<c:when test="${posicao.first}">
dt = dt + ' - <b>ATUAL</b>';
atual = pt;
createMarkerAtual(pt,cod,dt,bt,map);
</c:when>
<c:when test="${posicao.last}">
dt = dt + ' - <b>PARTIDA</b>';
inicio = pt;
createMarkerPartida(pt,cod,dt,bt,map);
</c:when>
<c:otherwise>
createMarker(pt,cod,dt,bt,map);
</c:otherwise>
</c:choose>
</c:forEach>
var flightPath = new google.maps.Polyline({
path:myTrip,
strokeColor:"#0000FF",
strokeOpacity:0.5,
strokeWeight:4
});
flightPath.setMap(map);
map.fitBounds(bounds);
distTotal(atual,inicio);
}
function calcEnderecos() {
<c:forEach var="listaEndereco" varStatus="posicao" items="${listaEndereco}">
var dt = '${listaEndereco.dtSistema}';
var lat = '${listaEndereco.idLatitude}';
var lng = '${listaEndereco.idLongitude}';
var pt = new google.maps.LatLng(lat, lng);
/*ERRO AQUI - Syntax error on token "_$tag______", ; expected*/
<c:choose>
<c:when test="${posicao.first}">
dt = dt + ' - <b>ATUAL</b>';
atual = pt;
codeLatLng(pt,dt);
</c:when>
<c:when test="${posicao.last}">
dt = dt + ' - <b>PARTIDA</b>';
inicio = pt;
codeLatLng(pt,dt);
</c:when>
<c:otherwise>
codeLatLng(pt,dt);
</c:otherwise>
</c:choose>
</c:forEach>
}
/*ERRO AQUI - Syntax error on token "_$tag______", ; expected*/
function codeLatLng(point, data){
var geocoder = new google.maps.Geocoder();
var summaryPanel = document.getElementById('directions_panel');
summaryPanel.innerHTML = '';
geocoder.geocode({'latLng': point}, function(results, status){
if (status == google.maps.GeocoderStatus.OK){
summaryPanel.innerHTML+= '<b>Data: </b>' + data;
summaryPanel.innerHTML+= '<br><b>Endereço: </b>' + results[0].formatted_address + '';
summaryPanel.innerHTML+= '<br><b>_____________________________________________________________________________________________________________<br><br></b>';
} else {
}
});
}
function endereco(info,point,dt, bt){
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'latLng': point}, function(results, status){
if (status == google.maps.GeocoderStatus.OK){
/*ERRO AQUI - Syntax error on token "_$tag_____", invalid AssignmentOperator*/
if (bt == 100){
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/100.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
} else if (bt < 100 && bt > 75){
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/75.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
} else if (bt < 75 && bt > 50){
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/50.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
} else if (bt < 50 && bt > 35){
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/35.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
} else if (bt < 35 && bt > 15){
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/15.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
} else {
infowindow.setContent('<IMG BORDER="0" ALIGN="Right" SRC="img/0.png"> <b>Bateria: </b>' + bt + '%' + '<br><b>Rastreador:</b> ' + info + '<br><b>Data: </b>' + dt + '<br><b>Endereço: </b>' + results[0].formatted_address);
}
} else {
}
});
}
function distTotal(start,end) {
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
function computeTotalDistance(result) {
var total = 0;
var myroute = result.routes[0];
for (var i = 0; i < myroute.legs.length; i++) {
total += myroute.legs[i].distance.value;
}
total = total / 1000.
document.getElementById('total').innerHTML = total + ' m';
}
Nem imagino o que seja isso…