[OpenLayers-Users] GML/KML feeds not loading

Michael Angstadt mangstadt at jbisoft.com
Tue Dec 30 10:33:46 EST 2008


The CBSNews feed does contain a city and state/country, but actually 
parsing this data, getting Google to geocode it, and plotting it on the 
OpenLayers map would take more effort than we're willing to 
expend...unless this is common with KML files, which doesn't seem to be 
the case.

Brad Spencer wrote:
> You can call Google's geocoding engine as a web service to geocode addresses
> on the fly. I think there may be some limits on large batch numbers and of
> course there is that licensing/copyright issue with Google.
>
> maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&outp
> ut=xml&sensor=true_or_false&key=abcdefg..etc
>
> The result is a XML file containing an errorCode, accuracyIndicator, lat,
> long
>
> Maybe this can help you for part of your problem.
>
> Cheers, Brad....
>
>
>
> -----Original Message-----
> From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
> Behalf Of Christopher Schmidt
> Sent: Tuesday, December 30, 2008 4:35 AM
> To: Michael Angstadt
> Cc: users at openlayers.org
> Subject: Re: [OpenLayers-Users] GML/KML feeds not loading
>
> 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:coordi
> nates></gml:Point></ogr:geometryProperty>
>
> Which isn't anywhere I know how to find.       
>
> Regards,
>   



More information about the Users mailing list