cs_imoum
Messages postés34Date d'inscriptionmardi 2 août 2011StatutMembreDernière intervention24 avril 2012
-
24 avril 2012 à 14:51
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020
-
24 avril 2012 à 15:41
Bonjour,
le code ci-dessous normalement me permet de afficher un infowindow lorsque je clique sur un marqueur sur google maps mais ça marche pas
c'est quoi le problème??
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialisation(){
var centreCarte = new google.maps.LatLng(36.80278, 10.17972);
var optionsCarte = {
zoom: 10,
center: centreCarte,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var maCarte = new google.maps.Map(document.getElementById("EmplacementDeMaCarte"), optionsCarte);
<% try {
Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/projet", "root", "");
Statement st = con.createStatement();
String query = "SELECT longitude, latitude, nom_medecin FROM medecin ";
System.out.println("query : " +query);
ResultSet rs = st.executeQuery(query);
while(rs.next())
{
float lg =rs.getFloat("longitude");
float lat =rs.getFloat("latitude");
String name = rs.getString("nom_medecin");
System.out.println("latitude= "+ lat+" et longitude= "+ lg+ " et nom du medecin est: "+name);
%>
var centreMarker = new google.maps.LatLng(<%=lat%>, <%=lg%>);
var optionsMarqueur = {
position: centreMarker,
map: maCarte,
title: "<%=name%>"
}
var marqueur = new google.maps.Marker(optionsMarqueur);
var contentstring = 'Info Window'
var infowindow = new google.maps.InfoWindow({content: contentstring});
google.maps.event.addListener(marqueur,'click',function(){
infowindow.setContent(this.html);
infowindow.open(map,marqueur);
});
<% }
rs.close();
con.close(); }
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
%>
}
google.maps.event.addDomListener(window, 'load', initialisation);
</script>