My goal is to get markers from my datastore.  An earlier post I
submitted didn't get any responses on that so I'm on Plan B which is
to have my GAE servlet pull from the datastore and create an XML
stream.  My KML from the servlet works when I view source and grab the
KML.  But I don't think I'm creating (or maybe using) the output
correctly because my map does not show the KML layer.  My KML is
listed below but there are also web page headers which I think is
messing things up.  Don't know how to output a stream that looks like
a file.

Also, when I use a file (shown below: test.kml) that I generated by
copying and pasting the servlet's output, the markers of the KML layer
show up but the layer appears to have an opaque background so I cannot
see the underlying map.  Note: I want the KML layer to always show
rather than letting the user toggle the layer as in some examples I've
seen.

Here's the code and the KML.  Any help would be greatly appreciated!
John


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


<%
String geotagLatMember = "";
String geotagLonMember = "";
geotagLatMember = (String)request.getAttribute("startLat");
geotagLonMember = (String)request.getAttribute("startLon");
Long memberId = (Long)request.getAttribute("memberId");
Long deptId = (Long)request.getAttribute("deptId");
List<Geotag>  inboundGeotags =
(List<Geotag>)request.getAttribute("inboundGeotags");
%>

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>responder-IQ</title>
<link rel="stylesheet" href="stylesheets/main.css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?
sensor=false"></script>
<!--<script type="text/javascript" src="http://gmaps-utility-
library.googlecode.com/svn/trunk/markermanager/release/src/
markermanager.js"></script>-->
<script type="text/javascript">

var geotagLayer =  null;
var map;
var marker;
var image = 'icon48.png';

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

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

  geotagLayer = new google.maps.KmlLayer('http://responder-
iq.appspot.com/test.kml');
  geotagLayer.setMap(map);

  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();

}

</script>
</head>

<body onload="initialize()">

                <table>
                <tr class="tall"><td class="ph_red wide medium">TEST</td>

                <td class="ph_white small"
                onClick="javascript:window.location.href='department?
action=deptDisplay'">
                <a href="department?action=deptDisplay">Back</a></td></tr>

                <tr><td class="black small" colspan="2">GEOTAG: Create</td></
tr>

                <tr><td colspan='2'>
                <div id="map_canvas" style="width:280px; height:280px"></div>
                </td></tr>
                <form method="post" action="department?action=geotagCreate">
                <tr><td class="tall left medium yellow" colspan="2"
                        onClick="javascript:window.location.href='geotag?
action=geotagPrepCreate'">
                        <a 
href="geotag?action=geotagPrepCreate">Refresh</a></td></tr>

                <tr><td class="tall medium green" colspan="2">
                <a href="#" 
onclick="javascript:document.forms[0].submit();return
false;">Submit</a></td></tr>

                <input type="hidden" name="geotagmemberId" value="<%= memberId 
%>"></
input>
                <input type="hidden" name="geotagdeptId" value="<%= deptId 
%>"></
input>
                <input type="hidden" id="lat" name="geotagLat">
                <input type="hidden" id="lng" name="geotagLon">

                <tr class="nobottom left"><td colspan="2" class="gray 
small">Title:</
td></tr>
                <tr class="notop left"><td colspan="2" class='small'><input
type="text" name="geotagTitle" ></td></tr>

                <tr class="nobottom left"><td colspan="2" class="gray
small">Description:</td></tr>
                <tr class="notop left"><td colspan="2" class='small'><input
type="text" name="geotagDescription" ></td></tr>

                <tr class="nobottom left"><td colspan="2" class="gray
small">Latitude:</td></tr>
                <tr class="notop left"><td colspan="2">
                <div id="latitude"  style="height:25px; margin-left:5px; 
margin-top:
5px"></div></td></tr>

                <tr class="nobottom left"><td colspan="2" class="gray
small">Longitude:</td></tr>
                <tr class="notop left"><td colspan="2">
                <div id="longitude" style="height:25px; 
margin-left:5px"></div></
td></tr>

                </form>
                </table>

</body>
</html>



KML (this is the xml but the file generated has webpage headers etc...
not sure how to generate a properly formatted KML file or stream in
real-time...

HEADER
Page (supposed to be a file or stream) header information contains:
Request URL:http://responder-iq.appspot.com/geoXML?action=geotagXML
Request Method:GET
Status Code:200 OK
Request Headers
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5
Referer:http://responder-iq.appspot.com/adminMenu.html
User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4
Response Headers
Content-Length:794
Content-Type:text/html
Date:Tue, 18 May 2010 20:00:44 GMT
Server:Google Frontend)

KML

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://
earth.google.com/kml/2.1"><Document>
<Placemark><name>H21</name><description>Test 2</
description><Point><coordinates>40.899692235350464,-74.4284745449829</
coordinates></Point></Placemark>
<Placemark><name>H98</name><description>Test 5</
description><Point><coordinates>40.90416850893566,-74.42632877777099</
coordinates></Point></Placemark>
<Placemark><name>B533l</name><description>Test 45</
description><Point><coordinates>40.90254670567765,-74.43525516937255</
coordinates></Point></Placemark>
<Placemark><name>H87</name><description>Hydrant</
description><Point><coordinates>40.90403876613856,-74.42083561370849</
coordinates></Point></Placemark>
</Document></kml>

-- 
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