bonjour, on application est de réaliser une interface web avec j2E de géolocalistaion des véhicules et afficher sur le map l'historique de déplacement d'une véhicule choisie avec des marqueures. et les véhicules et les positions correspondants sont enregistrés dans mysql table. j'ai réussit d'afficher le map et d'afficher les marqueures aussi mais mon problème que de choisir l'une des véhicules et afficher juste ses traces pas d'afficher tou les traces. s'il vous plait s'il ya quelqu'un pour m'aider.
mon code sources et le suivant:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Geolocalisation</title>
<link rel="stylesheet" href="style.css" media="screen"/>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var position = new google.maps.LatLng(33.8626, 10.1036);
var image = 'images/MapMarker_Ball__Chartreuse.png';
var image1 = 'images/MapMarker_Ball__Pink.png';
var image2 = 'images/MapMarker_Ball__Azure.png';
var myOptions = {
zoom: 13,
center: position,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
 
var map = new google.maps.Map(
document.getElementById("map_canvas"),
myOptions);
 
<% try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection cnx=DriverManager.getConnection("jdbc:mysql://localhost:3306/data","root","admin");
Statement st = cnx.createStatement();
String query = "SELECT id_device, latitude, longitude, statut FROM cordone ";
System.out.println("query : " +query);
ResultSet rs = st.executeQuery(query);
while(rs.next())
{ float lat =rs.getFloat("latitude");
float lg =rs.getFloat("longitude");
String stat=(rs.getString("statut"));
String device=(rs.getString("id_device"));
System.out.println("latitude= "+ lat+ " longitude= "+ lg + " statut= "+ stat+ " id= "+ device);
 
%>
<%if(stat.equals("start")){%>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<%=lat%>, <%=lg%>),
map: map,
icon: image,
 
});
 
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});<%}
else if(stat.equals("en mouvement")){%>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<%=lat%>, <%=lg%>),
map: map,
icon: image2,
 
});
 
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});<%}
else if(stat.equals("stop")){%>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<%=lat%>, <%=lg%>),
map: map,
icon: image1,
 
});
 
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});<%}
}
 
 
 
rs.close();
cnx.close(); }
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
%>
 
}
 
</script>
</head>
 
<SELECT NAME="location" onChange= "disp_text() " >
<option value="">--- Recherche des vehicuels: ----</option>
<% try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection cnx=DriverManager.getConnection("jdbc:mysql://localhost:3306/data","root","admin");
Statement st = cnx.createStatement();
ResultSet rs=st.executeQuery("select id_vehicule from test where id_client ='"+ s +"'");
while(rs.next())
 
{%>
<option value="<%=rs.getString("id_vehicule")%>"><%=rs.getString("id_vehicule")%></option>
 
 
<%}}
catch(Exception e)
 
{
e.printStackTrace(new PrintWriter(out));
}%>
 
</select>
<div id="map_canvas" style="width: 700px; height: 500px"></div>
 
 
 
<body onload="initialize()">
 
</body>
</html>