I have a controller (address /Home/Test see below) which definately responds to get request with this:
<?xml version="1.0" encoding="utf-8"?><kml xmlns=".2"><Placemark><name>Simple placemark</name><description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.</description><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark></kml>
It is like a feed which responds with data (application/vnd.google-earth.kml+xml) to a get request.
I am using this javascript:
<script type="text/javascript" src=";region=GB"></script>
<script type="text/javascript" src="/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var latlng = new google.maps.LatLng(37.42228990140251, -122.0822035425683);
var options = {
zoom: 17,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
//alert(georssLayer);
var georssLayer = new google.maps.KmlLayer('/Home/Test');
georssLayer.setMap(map);
});
</script>
The map is shown but nothing at -122.0822035425683,37.42228990140251.
Any ideas?
Maybe I missunderstand what KmlLayer does? I presume it performs a get request and then overlays the map ...
Christian
I have a controller (address /Home/Test see below) which definately responds to get request with this:
<?xml version="1.0" encoding="utf-8"?><kml xmlns="http://www.opengis/kml/2.2"><Placemark><name>Simple placemark</name><description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.</description><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark></kml>
It is like a feed which responds with data (application/vnd.google-earth.kml+xml) to a get request.
I am using this javascript:
<script type="text/javascript" src="http://maps.google./maps/api/js?sensor=false®ion=GB"></script>
<script type="text/javascript" src="/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var latlng = new google.maps.LatLng(37.42228990140251, -122.0822035425683);
var options = {
zoom: 17,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
//alert(georssLayer);
var georssLayer = new google.maps.KmlLayer('/Home/Test');
georssLayer.setMap(map);
});
</script>
The map is shown but nothing at -122.0822035425683,37.42228990140251.
Any ideas?
Maybe I missunderstand what KmlLayer does? I presume it performs a get request and then overlays the map ...
Christian
Share Improve this question edited Aug 12, 2010 at 12:42 cs0815 asked Aug 12, 2010 at 12:28 cs0815cs0815 17.4k47 gold badges155 silver badges322 bronze badges 1- You cannot use /home/test. See this answer from a few days ago: stackoverflow./questions/3435566/google-maps-kml-files – Marcelo Commented Aug 12, 2010 at 12:56
1 Answer
Reset to default 7At http://code.google./apis/maps/documentation/javascript/overlays.html notice this: 'The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. These data formats are displayed on a map using a KmlLayer object, whose constructor takes the URL of a publicly accessible KML or GeoRSS file.' It looks to me like your request is local; move it to a server which Google can see.