Most of the examples I've read through assume a populated array in the
Javascript.  Unfortunately I'm having trouble figuring out how to get
the results of my server-side query result set into an array so I can
show them on a map.

My intent was to grab the inbound Geotags (the System.out.println
tells me there are six in the List) and get the Lat, Long and Label
for each and make a marker...

<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="commandview.entity.*"%>
<%@ page import="java.io.IOException"%>


<%
....
List<Geotag>  inboundGeotags =
(List<Geotag>)request.getAttribute("inboundGeotags");
System.out.println("geotagCreateSize: " + inboundGeotags.size());
%>


Then I'm loading them (these are the existing marker locations which
are not draggable) onto the map:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?
sensor=false"></script>
<script type="text/javascript">

var map;
var marker;

function initialize() {
  var myInitialCenter = new google.maps.LatLng(<%=geotagLatMember%>,<
%=geotagLonMember%>);
  var myOptions = {
    zoom: 14,
    center: myInitialCenter,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }

  map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

// i realize this probably isn't real javascript but I left it in to
show my intent (and my noob status.)
    for (Geotag g : inboundGeotags) {
                var markerLatLng = (g.getlatitude(), g.getlongitude())
                    marker = new google.maps.Marker({
                    position: markerLatlng,
                    map: map,
                    title: g.getlabel();
                    System.out.println("insideForG: " + g.getlongitude());
                        });
        }
  google.maps.event.addListener(map, 'click', function(event) {
                placeMarker(event.latLng);
  });
}

function placeMarker(location) {
  if (marker) {
    marker.setPosition(location);
  } else {
    marker = new google.maps.Marker({
        position: location,
        map: map,
        draggable: true
    });
    google.maps.event.addListener(marker, 'position_changed',
showPosition);
    showPosition();
  }
 }

function showPosition() {

  document.getElementById("latitude").innerHTML  =
marker.getPosition().lat();
  document.getElementById("longitude").innerHTML =
marker.getPosition().lng();

  document.getElementById("lat").value = marker.getPosition().lat();
  document.getElementById("lng").value = marker.getPosition().lng();

}

Then I have another function for creating a new "Geotag" which works
fine (thanks to folks in this group) because it's basically a form
sending information back to the servlet in GAE.

So if anyone can point me toward an example that would be great.
Probably too rudimentary a question that might not fit in this Maps
group but I thought I'd ask.

Thanks!  John

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to