Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem on markers in google maps
    primarykey
    data
    text
    <p>iam pradeep i have a problem on google maps the problem is iam creating multiple markers based on the latitude and longitude which(latitude and longitude) i get from my database.</p> <p><strong>Here comes the problem.</strong> when i create the marker, only last marked is loaded on to the map rather than loading all the maps.</p> <p>Below you can see the code.</p> <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt; &lt;%@page import="java.sql.*" %&gt; &lt;%! Connection connection = null; boolean foundResults = false; ResultSet set = null; Statement statement = null; %&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt; &lt;style type="text/css"&gt; html { height: 100% } body { height: 100%; margin: 0px; padding: 0px } #map_canvas { height: 100% } &lt;/style&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; var locations; var h = new Array(10); function initialize() { var latlng = new google.maps.LatLng(17.4531555176, 78.4580039978); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); //google.maps.event.addListener(map, 'zoom_changed', function() { setTimeout(moveToDsnr, 500);}); google.maps.event.addListener(map, 'zoom_changed', function() { setTimeout(moveToAmpp, 500);}); var marker = new google.maps.Marker({position: latlng,map: map,title:"Hyderabad"}); google.maps.event.addListener(marker, 'click', function() { map.setZoom(12);}); } function moveToAmpp() { &lt;% String lat=null; String lng=null; int i=0; try { Class c = Class.forName("org.postgresql.Driver"); connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres", "password"); statement = connection.createStatement(); set = statement.executeQuery("SELECT lat, lng FROM latlng"); while(set.next()) //for(i=0;set.next();i++) { lat=set.getString(1); lng=set.getString(2); %&gt; alert(&lt;%= lat%&gt;); alert(&lt;%= lng%&gt;); locations = [['Dilsukhnagar', &lt;%= lat%&gt;, &lt;%= lng%&gt;, 1]]; alert(locations); var map = new google.maps.Map(document.getElementById("map_canvas"),{zoom: 12,center: new google.maps.LatLng(17.38,78.48),mapTypeId:google.maps.MapTypeId.ROADMAP}); var infowindow = new google.maps.InfoWindow(); var marker; var i; //alert(locations.length); alert(locations[0][0]); alert(locations[0][1]); alert(locations[0][2]); alert(locations[0][3]); for (i = 0; i &lt; locations.length; i++) { marker = new google.maps.Marker({position: new google.maps.LatLng(locations[i][1],locations[i][2]),map: map}); alert("done"); google.maps.event.addListener(marker, 'click', ( function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } }) (marker, i)); alert("created"); } alert("hello"); &lt;% } } catch(Exception e) { } %&gt; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()"&gt; &lt;div id="map_canvas" style="width:100%; height:100%"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So please help me on this. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload