I’m trying to load a kml on a google map but I cant do it. I’m loading the kml after a click event, and then I call to a function which contains the url:
function LoadRoute(latlng, param1, param2, param3) {
var georssLayer = new google.maps.KmlLayer('http://myserver.net/kmls/file.asp?id='+param1+'&date='+param2+' 00:00:00&EndDate='+param3+' 23:59:59');
georssLayer.setMap(map);
}
The above code doesnt load the kml, but In other hand if I load the same file downloaded directly it works, I mean, like this:
function LoadRoute(latlng, param1, param2, param3) {
var georssLayer = new google.maps.KmlLayer('http://myserver.net/kmls/file.kml');
georssLayer.setMap(map);
}
Does anyone knows what happen? I think it is about the parameters syntax. Anyway if I create another function containing the above url to check if it can be accessed by an url, it works too. For checking it, I open a new tab window to see if the url is well formed, and the result is that the file is donwloaded.
function open_in_new_tab(latlng, param1, param2, param3)
{
window.open('http://myserver.net/kmls/file.asp?id='+param1+'&date='+param2+' 00:00:00&EndDate='+param3+' 23:59:59', '_blank');
window.focus();
}
You have spaces in your URL:
That means it needs to be urlencoded
In javascript you can URL encode strings with escape