[OpenLayers-Users] GML/KML feeds not loading
Michael Angstadt
mangstadt at jbisoft.com
Tue Dec 30 10:16:24 EST 2008
Thanks for the thorough and very quick response!
> 1. You're probably violating the same origin policy.
>
> http://faq.openlayers.org/proxyhost/all/
>
> (Unless your HTML page is hosted on cbsnews.com, which is possible,
> but seems unlikely.)
I am indeed using a proxy. I set the ProxyHost variable right after I
create the Map object:
OpenLayers.ProxyHost = "proxy?url=";
> 2. You're attempting to load a NetworkLink. OpenLayers 2.7 does not
> support NetworkLinks, which was recently fixed in SVN. You can set
> your KML file to maxDepth: 2 or some such, and it will parse the
> networklink in the file you have but...
So you're saying that 2.7 *does* support NetworkLinks--you just have to
set the matchDepth property?
> Quite simply, the CBS news feed doesn't contain any locations, only
> addresses, so you need a full gazetteer for it to work. Calling this KML
> at all is simply more evidence that the KML spec is hopelessly
> overbroad, and since not even Google will read it, I have no qualms
> saying that OpenLayers won't.
Yeah, that feed was kind of odd. I found another one with actual
coordinates[1]. Like the CBSNews feed, it has a NetworkLink tag, which
links to another KML file with the actual map data. It works fine if I
plug it into Google Maps (it displays a number of points and vectors in
central Africa). However, I can't get it to work in OpenLayers.
Maybe it has something to do with it not using the proxy to load the
NetworkLink URL? If so, how can I get it to do this? I have the
maxDepth of the KML layer set to 3.
[1] http://www.janegoodall.org/news/gombe-blog/feed/gcb-feed.kml
-Mike
Christopher Schmidt wrote:
> On Mon, Dec 29, 2008 at 12:06:38PM -0500, Michael Angstadt wrote:
>
>> Good afternoon,
>>
>> I'm having trouble getting certain KML and GML feeds to load in
>> OpenLayers and I wonder if someone can help. The issue appears in
>> versions 2.6 and 2.7 of OpenLayers.
>>
>> Let me start with KML feeds. The feed taken from the "KML Layer
>> Example" on the examples section of the OpenLayers website[1] works just
>> fine. This feed draws a number of weird shapes in Arizona. However, I
>> cannot get another feed, taken from CBSNews' website, to work[2]. One
>> of my co-workers was able to view this in Google Earth just fine (see
>> attached screenshot). Is this feed only compatible with Google Earth?
>> I searched the bug tracking system and found a ticket that might be
>> relevant[3]. The ticket states that "the current KML class is a Format
>> & hence can only deal in Feature.Vector objects". This seems to explain
>> why the feed which displays vectors[1] works and the feed which displays
>> points[2] does not.
>>
>
> Points are vectors; images are not. The problems you're running into are
> probably three-fold:
>
> 1. You're probably violating the same origin policy.
>
> http://faq.openlayers.org/proxyhost/all/
>
> (Unless your HTML page is hosted on cbsnews.com, which is possible,
> but seems unlikely.)
>
> 2. You're attempting to load a NetworkLink. OpenLayers 2.7 does not
> support NetworkLinks, which was recently fixed in SVN. You can set
> your KML file to maxDepth: 2 or some such, and it will parse the
> networklink in the file you have but...
>
> 3. It appears that the linked file actually doesn't contain any
> geographic information. Instead, it contains just addresses...
> which, I guess, Google Earth looks up, but OpenLayers can't. I can
> imagine ways to deal with this, but my first one would be to
> complain to CBS that the KML that they're providing is useless to
> any non-Google Earth client.
>
> Additionally, Google Maps seems to think that the file is invalid.
> http://maps.google.com/maps?f=q&hl=en&geocode=&q=http:%2F%2Fwww.cbsnews.com%2Fcommon%2Fincludes%2Fgoogle%2Fcbsnewsfiles.kml&ie=UTF8&z=4
>
> Who am I to complain when Google says it's wrong?
>
>
>> So unless my Javascript code is incorrect, it seems like OpenLayers only
>> has *partial* support for KML feeds. Is this true? Is there any reason
>> why the CBSNews feed should not work in OpenLayers? Here is the
>> Javascript code I use to load the KML layer:
>>
>
> Quite simply, the CBS news feed doesn't contain any locations, only
> addresses, so you need a full gazetteer for it to work. Calling this KML
> at all is simply more evidence that the KML spec is hopelessly
> overbroad, and since not even Google will read it, I have no qualms
> saying that OpenLayers won't.
>
>
>> map.addLayer(new OpenLayers.Layer.GML(
>> 'CBSNews',
>> 'http://www.cbsnews.com/common/includes/google/cbsnews.kml',
>> {
>> format: OpenLayers.Format.KML,
>> formatOptions:
>> {
>> extractStyles: true,
>> extractAttributes: true,
>> maxDepth: 3
>> }
>> }
>> ));
>>
>> I have the identical issue with GML feeds. Example feeds taken from the
>> OpenLayers website[4,5] work fine (they draw shapes in France and Canada
>> respectively). But a GML feed a co-worker of mine found online[6] does
>> not. This co-worker has told me that the feed displays fine in Google
>> Earth and shows a number of points across the US (I don't have a
>> screenshot for this unfortunately).
>>
>
> I don't understand how this is possible, since the GML file has no
> projection data with it, and the file is in projected coordinates.
> Assuming you knew which coordinate reference system this was in, you
> could probably use it with OpenLayers, either by reprojecting it first
> or by using built in reprojection support, but without the actual
> SRS/CRS information, there's no way to know how to project it.
>
> Now, the GML file includes lat/long coordinates as feature attributes,
> so you could write a tool which would convert this GML, and perhaps that
> is something that some pro version of Google Earth suppots, but Google
> Earth won't even let me open this file, so I don't know what he's
> getting.
>
>
>> So, is it also true that OpenLayers only has *partial* support for GML
>> feeds? Here is my Javascript code for loading a GML layer:
>>
>
> No; we have full support for GML2, and this file parses correctly... but
> all its points end up off the upper right corner of the map, since
> they're coordinates like:
>
> <ogr:geometryProperty><gml:Point><gml:coordinates>451306,5291930</gml:coordinates></gml:Point></ogr:geometryProperty>
>
> Which isn't anywhere I know how to find.
>
> Regards,
>
More information about the Users
mailing list