be88ex / earth-api-samples

Automatically exported from code.google.com/p/earth-api-samples
1 stars 0 forks source link

fetchKml() error with relative URL #290

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Based on this thread:
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/
a7b809da56c33a9e/64fe01c98a9655e3?pli=1

What steps will reproduce the problem?
Javascript code where a kml URL passed to fetchKml is relative and not
absolute.

var kmlUrl = '/static/kml/' + file + '.kml';
google.earth.fetchKml(ge, kmlUrl, function(kmlObject) { ...

What is the expected output or behavior? What do you see instead?
Expect it to fetch the KML.  Instead see the following error in Firefox
console and KML doesn't load.
Error: Error calling method on NPObject!
Source File:
http://www.google.com/uds/api/earth/1.0/dfcdfd0d1a09b3ae4f7f02474b574a2f/default
.I.js
Line: 51

Which plugin version are you using?
5.0

Workaround is to use absolute URLs, e.g. in the code to reproduce the error
above:
var kmlUrl = 'http://localhost:8000/static/kml/' + file + '.kml';

Original issue reported on code.google.com by ndjen...@gmail.com on 19 Jul 2009 at 2:07

GoogleCodeExporter commented 8 years ago

Original comment by api.roman.public@gmail.com on 1 Aug 2009 at 12:15

GoogleCodeExporter commented 8 years ago
This is a regression - it used to work in v4.x. I can confirm the broken 
behaviour in
5.0.

Original comment by alastair.maw on 11 Aug 2009 at 1:01

GoogleCodeExporter commented 8 years ago
Actually, it's not a regression after all - this didn't work in 4.x either. 
Sorry for
the noise.

Original comment by alastair.maw on 11 Aug 2009 at 1:33

GoogleCodeExporter commented 8 years ago
I essentially qualified the URL so that I don't have to change all of the code.

qualifyUrl = function (inUrl) {
    var url = location.href;  // entire url including querystring - also: 
window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 7));
    var relativeURL = url.substring(0, url.lastIndexOf('/'));
    if (inUrl.indexOf("http://", 0) == 0){
        return inUrl;
    }
    else if (inUrl.indexOf('/',0) == 0) {
        return baseURL + inUrl;
    }
    else {
        return relativeURL + "/" + inUrl;
    }        
};

Original comment by jonetta.ng@gmail.com on 5 Jan 2010 at 9:26

GoogleCodeExporter commented 8 years ago

Original comment by jli...@google.com on 17 Mar 2010 at 6:37

GoogleCodeExporter commented 8 years ago
Please help with this issue. I need the plugin to load KMZ files with relative 
paths
to the embedded resources. Thanks

Original comment by robertsw...@gmail.com on 29 Apr 2010 at 2:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Is there are reason this issue has seen no activity? Accepting relative URL's 
is such a fundamental part of using a JavaScript API, especially one that is 
going to "handle" pulling down data itself, that it's extremely distressing to 
see this go unresolved for so long.

Original comment by daniel.l...@gmail.com on 21 Feb 2012 at 9:52

GoogleCodeExporter commented 8 years ago
It is really quite simple.  Google uses the absolute URL to "authorize" your 
use of the plugin.  One of their (stupid) requirements is that your files be 
visible to the world.  In order to determine that google turns around after you 
call fetchKml() and checks to see if the url passed in can be seen from outside 
your network.  If it cannot, floop, fail.  A relative url will not work outside 
your network so it thinks your cheating.

What really sucks here is that google do NOT give the real error , nor do they 
comment on these issues when they know full well why your having the problem.

Original comment by gik...@gmail.com on 30 Apr 2013 at 1:53