Were you thinking something like this sample code? Only with an
Array? I already have the List loaded. I would be passing in lat,
lng and a String label in a single geotag object. Not sure if this
helps... I'm still looking for something that fits. Thanks again for
any assistance. John
<html>
<head>
<title>Array Elements</title>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%
Format formatter = new SimpleDateFormat("MMMM");
Calendar calendar = Calendar.getInstance();
String[] monthName = new String[12];
for (int i = 0; i < 12; i++) {
calendar.set(Calendar.MONTH, i);
monthName[i] = formatter.format(calendar.getTime());
}
int month = monthName.length;
%>
</head>
<body>
<script>
var month = new Array(<%=month%>);
<%for (int i = 0; i < month; i++) {%>
month[<%=i%>] = "<%=monthName[i]%>";
<%}%>
document.write("<h2>Elements of the array</h2>");
for( i = 0; i < month.length; i++){
document.write("<b>"+month[i]+"</b><br>");
}
</script>
</body>
</html>
On May 11, 6:30 pm, Daniels Lee™ <[email protected]> wrote:
> You'll need to input these Geotags into JavaScript collection, meaning it
> probably should output them within the <script> tags into some JS object.
>
> What results are you currently seeing on your test page?
>
>
>
>
>
> On Sun, May 9, 2010 at 8:49 PM, mlvfd <[email protected]> wrote:
> > 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]<google-maps-js-api-v3%2B
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> Daniels Lee
> Developer Programs Engineer
> Google, Inc.
> 345 Spear Street
> San Francisco, CA 94105
> 650 253 0967
>
> --
> 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
> athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
--
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.