Bonjour,

dans une jsp, j'utilise l'api de google map. Pour afficher les différents marker, j'utilise un fichier xml. Pour commencer, j'ai créé ce fichier à la main et l'ai mis dans le classpath. Jusque là pas de problème. Maintenant, je voudrai créer ce fichier du coté serveur à partir de la DB, mais je ne sais pas comment faire pour y accéder dans la jsp.

ma jsp:
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
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<html>
  <head>
    <title>Organiser une r&eacute;union</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAA70FDjbuxl9DIRqEfZN9IRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSNNUqIsSPkke4swap67gHzSSuiYA" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));        
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        
        // Create a special marker for the base location
        function createBase(addressBase){
                var geocoder = new GClientGeocoder();
                geocoder.getLatLng(addressBase,
                        function(point) {
                                if (!point) {
                                        alert(addressBase + " not found");
                                } else {
                                    map.setCenter(point, 10);
                                    var tinyIcon = new GIcon(G_DEFAULT_ICON);
                                    tinyIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
                                    tinyIcon.iconSize = new GSize(32, 32);
                                    markerOptions = { icon:tinyIcon };
                                    var marker = new GMarker(point, markerOptions);
                                    //alert(point);
                                    GEvent.addListener(marker, "click", function() {
                                        var myHtml = "<b><i> You </i></b>";                             
                                        map.openInfoWindowHtml(point, myHtml);
                                });
                                    map.addOverlay(marker);                         
                                }
                        }
                );
        }
            
        // Creates a marker at the given point with the given name and firstname
        function createMarker(address, name, firstname) {
                var geocoder = new GClientGeocoder();
            geocoder.getLatLng(address,
                function(point) {
                        if (!point) {
                                alert(address + " not found");
                        } else {
                            var marker = new GMarker(point);
                            GEvent.addListener(marker, "click", function() {
                                        var myHtml = "<i>" + name + " " + firstname + "</i>";                           
                                        map.openInfoWindowHtml(point, myHtml);
                        });
                            map.addOverlay(marker);                         
                        }
                }
            );
        }
        
        GDownloadUrl("data.xml", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
                          var base = parseFloat(markers[i].getAttribute("base"));
                          var address = markers[i].getAttribute("address");
              if(base == 1){
                  createBase(address);
              } else {              
                      var name = markers[i].getAttribute("name");
                      var firstname = markers[i].getAttribute("firstname");
                      createMarker(address, name, firstname);
              }
          }
        });
      }
    }
    //]]>
    </script>
  </head>
 
  <body onload="load()" onunload="GUnload()">
  <div id="map"  style="width: 800px; height:600px;"></div>
  </body>
</html>
Merci de vos réponses