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









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 '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 '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 '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 '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
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
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 ADS
Version of com.jdroidframework>jdroid-android-google-maps dependency
List of Version of com.jdroidframework>jdroid-android-google-maps dependency
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
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
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.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.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.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.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.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.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.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
Maven Dependency jdroid-android-google-maps >> 0.9.5
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-android-google-maps version0.9.5 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
Google maps GPS tracking
enabled on Google maps. Recently released GE 4 Beta (December 16) has a compatible... if a person has GPS on his mobile, he will find the accuracy of Google Maps... in locating the current location of a device or a person. Google Maps does
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.14.0
-android-google-maps version 0.14.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.14.0 Java library in your... for jdroid-android-google-maps version 0.14.0 In this section have given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.12.0
-android-google-maps version 0.12.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.12.0 Java library in your... for jdroid-android-google-maps version 0.12.0 In this section have given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.14.0
-android-google-maps version 0.14.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.14.0 Java library in your... for jdroid-android-google-maps version 0.14.0 In this section have given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.13.0
-android-google-maps version 0.13.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.13.0 Java library in your... for jdroid-android-google-maps version 0.13.0 In this section have given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.13.0
-android-google-maps version 0.13.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.13.0 Java library in your... for jdroid-android-google-maps version 0.13.0 In this section have given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for jdroid-android-google-maps version 0.12.0
-android-google-maps version 0.12.0. You can add these depency in your project to get com.jdroidframework:jdroid-android-google-maps:0.12.0 Java library in your... for jdroid-android-google-maps version 0.12.0 In this section have given
Maven dependency for com.jdroidframework - jdroid-android-google-maps version 0.13.0 is released. Learn to use jdroid-android-google-maps version 0.13.0 in Maven based Java projects
of jdroid-android-google-maps released The developers of   com.jdroidframework - jdroid-android-google-maps project have released the latest version... - jdroid-android-google-maps library is 0.13.0. Developer can use this version
Interactive Maps
on particular area is done it should zoom in ie. how it happens in google maps. I want zoom...Interactive Maps  Hi....................... How can u make maps interactive using java code. I mean if a map of some location is stored in database
Google Web Toolkit
Google Web Toolkit       Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't
DYNAMIC BINDING
DYNAMIC BINDING  WHAT IS DYNAMIC BINDING
jsp maps api example - JSP-Servlet
jsp maps api example  Can u give a complete working example on usage of JSP GOOGLE MAP API
how it maps to Struts
how it maps to Struts  What is MVC and how it maps to Struts
dynamic report
dynamic report  i need complete code for generating dynamic report in jsp
dynamic polymorphism
dynamic polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism
ModuleNotFoundError: No module named 'maps'
ModuleNotFoundError: No module named 'maps'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'maps' How to remove the ModuleNotFoundError: No module named 'maps' error
ModuleNotFoundError: No module named 'maps'
ModuleNotFoundError: No module named 'maps'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'maps' How to remove the ModuleNotFoundError: No module named 'maps' error
ModuleNotFoundError: No module named 'maps'
ModuleNotFoundError: No module named 'maps'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'maps' How to remove the ModuleNotFoundError: No module named 'maps' error

Ads