title: Google maps JSP in Spring
body: <p>I have a quite big and mysterious problem. I would like to dynamically add markers to google map placed on my JSP page with coordinates from my database.</p>
  
  <p>So my code looks like this one :</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
                  var map;
                  var markers = [];
  
                  function initialize() {
                      var options = {
                          mapTypeControlOptions: {
                              mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.TERRAIN],
                              style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                          }
                      }
  
                  &lt;%
                      String id_wydarzenia_session = null;
                      List&lt;Koordynaty&gt; koordynaty = null;
                      Double szer = null;
                      Double wys = null;
                      try {
                          id_wydarzenia_session = session.getAttribute("id_wydarzenia").toString();
                          WydarzenieDaoImpl wydarzeniedao = new WydarzenieDaoImpl();
                          koordynaty = wydarzeniedao.pobierzKoordynatyWydarzenia(id_wydarzenia_session);
                      } catch (Exception e) {
                          System.out.println(e.getMessage());
                      }
  
  
                  %&gt;
                      var wysokoscCenter = "&lt;%=koordynaty.get(0).getSzerokosc()%&gt;";
                      var szerokoscCenter = "&lt;%=koordynaty.get(0).getWysokosc()%&gt;";
                      map = new google.maps.Map(document.getElementById('map'));
                      map.setCenter(new google.maps.LatLng(wysokoscCenter, szerokoscCenter));
                      map.setZoom(17);
                      map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
  
                  &lt;%
                      Iterator&lt;Koordynaty&gt; iteratorKoordynaty = koordynaty.iterator();
                      while (iteratorKoordynaty.hasNext()) {
                          Koordynaty koordynatyDetails = iteratorKoordynaty.next();
                  %&gt;
                      addMarker(new google.maps.LatLng(koordynatyDetails.getWysokosc(), koordynatyDetails.getSzerokosc()), "Marker");
                  &lt;%
                      }
                  %&gt;
  
                  }
                  function addMarker(latlng, myTitle) {
                      markers.push(new google.maps.Marker({
                          position: latlng,
                          map: map,
                          title: myTitle,
                          icon: "http://maps.google.com/mapfiles/marker" + String.fromCharCode(markers.length + 65) + ".png"
                      }));
                  }
              &lt;/script&gt;
  </code></pre>
  
  <p>I checked in <code>addMarker</code> function that every coordinates are passed good, but map does not show up. I really really do not know how to fix this ;/</p>