Dynamic google maps

Dynamic google maps

I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only displays the last marker from the table.I think the problem is on my javascript var locations array.I have a problem on how to parse data to google map's javascript locations array.Please help me.Here is my source code.

<%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@page import="cgs.seismicEvents.DBConnection.DBUtility"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="javaQuery.j2ee.*"%> <%@ page import="javaQuery.importClass.javaQueryBundle"%> <%@ page import="java.sql.*"%>

<!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>GeoLocation</title>

<%! Connection con = null; ResultSet rs = null; Statement stmt = null; //GeoLocation $gl; //String ipaddress = null; float event_Size; double latitude; double longitude; Timestamp event_date; %> <% String query="SELECT EVENTSIZE,LATITUDE,LONGITUDE,EVENTDATE FROM EVENTS where EVENTDATE>=currentdate-30 order by EVENT_DATE desc"; con = DBUtility.getConnection(); try { stmt=con.createStatement(); } catch (SQLException e1) {

    request.getSession().invalidate();
    e1.printStackTrace();
}
try {
    rs = stmt.executeQuery(query);
} catch (SQLException e) {

    request.getSession().invalidate();
    e.printStackTrace();
}
%>

<%

while(rs.next()) { latitude = rs.getDouble("LATITUDE"); longitude =rs.getDouble("LONGITUDE"); eventSize=rs.getFloat("EVENTSIZE"); eventdate=rs.getTimestamp("EVENTDATE");

        System.out.println("var locations = new google.maps.LatLng("+event_Size+","+latitude+","+longitude+","+event_date+");\n");

}

%> 
<div id="map" style="width: 1400px; height: 900px;"></div>
  <script type="text/javascript">


        <%--My problem is here,I want to get values from the resultset and parse them   to this array--%>
        var locations =[

            ["<%=event_Size%>","<%=latitude%>","<%=longitude %>","<%=event_date%>]



  ];

   var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-25.731340,28.218370),
      mapTypeId: google.maps.MapTypeId.HYBRID
    });

    var infowindow = new google.maps.InfoWindow();

    var marker;
    var i;
    for (i = 0; i < locations.length; i++){
       // var data=locations[i];
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1],locations[i][2]),


         icon:{
         path: google.maps.SymbolPath.CIRCLE,            
         scale: 4
      },
        map: map
      });
        document.write();

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function(){
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        };
      })(marker, i));
    }

View Answers

Ads









Related Tutorials/Questions & Answers:
Dynamic google maps
Dynamic google maps  I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only... var locations array.I have a problem on how to parse data to google map's
Dynamic google maps
Dynamic google maps  I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only... var locations array.I have a problem on how to parse data to google map's
Advertisements
Dynamic google maps
Dynamic google maps  I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only... var locations array.I have a problem on how to parse data to google map's
Dynamic google maps
Dynamic google maps  I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only... var locations array.I have a problem on how to parse data to google map's
Dynamic google maps
Dynamic google maps  I have to read data from a database and show it as markers on google map.I have done that but i am stucked because my map only... var locations array.I have a problem on how to parse data to google map's
license for google maps - iPhone SDK
license for google maps - iPhone SDK  Do i need a license to display the locations on google map in my iPhone application
ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai'
ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai'  Hi...: No module named 'cmsplugin-google-maps-ai' How to remove the ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai' error? Thanks  
ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai'
ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai'  Hi...: No module named 'cmsplugin-google-maps-ai' How to remove the ModuleNotFoundError: No module named 'cmsplugin-google-maps-ai' error? Thanks  
ModuleNotFoundError: No module named 'django-google-maps'
ModuleNotFoundError: No module named 'django-google-maps'  Hi, My... named 'django-google-maps' How to remove the ModuleNotFoundError: No module named 'django-google-maps' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1'
ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1' ...: ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1' How to remove the ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1'
ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1'
ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1' ...: ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1' How to remove the ModuleNotFoundError: No module named 'google-maps-streetview_publish-v1'
ModuleNotFoundError: No module named 'python-simple-google-maps'
ModuleNotFoundError: No module named 'python-simple-google-maps'  Hi...: No module named 'python-simple-google-maps' How to remove the ModuleNotFoundError: No module named 'python-simple-google-maps' error? Thanks  
ModuleNotFoundError: No module named 'python-simple-google-maps'
ModuleNotFoundError: No module named 'python-simple-google-maps'  Hi...: No module named 'python-simple-google-maps' How to remove the ModuleNotFoundError: No module named 'python-simple-google-maps' error? Thanks  
ModuleNotFoundError: No module named 'trytond-google-maps'
ModuleNotFoundError: No module named 'trytond-google-maps'  Hi, My... named 'trytond-google-maps' How to remove the ModuleNotFoundError: No module named 'trytond-google-maps' error? Thanks   Hi
get latitude and longitude from google maps
get latitude and longitude from google maps  How to get the latitude and longitude from google maps
Google Zeitgeist-Trends-maps mashup
Google Zeitgeist-Trends-maps mashup       A usable mashup of google trends and zeitgeist most popular on google maps to show _where_ what is most popular Read full Description
Version of com.jdroidframework>jdroid-android-google-maps dependency
List of Version of com.jdroidframework>jdroid-android-google-maps dependency
ModuleNotFoundError: No module named 'gapic-google-maps-streetview-publish-v1'
ModuleNotFoundError: No module named 'gapic-google-maps-streetview-publish-v1...: ModuleNotFoundError: No module named 'gapic-google-maps-streetview-publish-v1' How to remove the ModuleNotFoundError: No module named 'gapic-google-maps
ModuleNotFoundError: No module named 'proto-google-maps-streetview_publish-v1'
ModuleNotFoundError: No module named 'proto-google-maps-streetview_publish-v1...: ModuleNotFoundError: No module named 'proto-google-maps-streetview_publish-v1' How to remove the ModuleNotFoundError: No module named 'proto-google-maps
Maven Dependency jdroid-android-google-maps >> 0.10.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.10.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.12.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.12.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.3
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.3 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.6
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.6 in your project
Maven Dependency jdroid-android-google-maps >> 0.10.1
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.10.1 in your project
Maven Dependency jdroid-android-google-maps >> 0.11.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.11.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.13.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.13.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.8.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.8.0 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.1
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.1 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.2
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.2 in your project
Maven Dependency jdroid-android-google-maps >> 0.9.4
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.4 in your project

Ads