Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to get a kml from a URL to display in OpenLayers. However, it is a ground overlay so it cannot be displayed the standard way. I found this thread: Does OpenLayers supports KML Ground Overlays? However, I am very lost as to how to parse this manually. I know I can make an AJA request and parse it, but don't think I can do that bc of cross-domain issues.

So could someone guide me in the right diirection to get a KML parsed directly from a url?

Thanks!

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

If your openlayers application is already using a proxy, in my case i'm using OpenLayers.ProxyHost = "proxy/proxy.ashx?url="; You can use that to download your KML.

For example the url you would use in your ajax request is:

proxy/proxy.ashx?url=http://anotherdomain/thekml.kml

If you are not currently using a proxy file for these reasons you could make one or download one. It's basically just a handler. Depending on what platform/framework you're using on the backend... PHP, .NET, etc.

This way the browser does not request the KML. The request goes to your application server and your application server makes the request, then returns the response to the browser.

share|improve this answer
    
Thanks! I was thinking I would have to do that. But hoping there was a solution that would be easier since openlayers can normally grab a kml just fine from a url. This cross-domain ajax stuff is what causes the biggest headaches for me! –  KyleK Sep 12 '12 at 15:15
    
yeah well, I would definitely try to do it without the proxy first, it might work and save yourself the trouble. But in case it does not, you can always use the proxy. –  CaptDragon Sep 12 '12 at 15:20
    
Hey CaptDragon, this got me thinking about something. I was able to make my openlayers proxy work for a GetFeatureInfo request by just adding the url of the data into the cgi and making a call to the regular url. I have this:OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; at the top of my code. However, if I am not using the OpenLayers API to GET this kml, do I have to make the url:"/cgi-bin/proxy.cgi?url=KML_URL"; in my GET? Sorry if this is confusing. –  KyleK Sep 12 '12 at 16:08
    
Normally, yes, you still have do have to make the url /cgi-bin/proxy... even without OpenLayers because it would be the browser making the CB GET request and I'm pretty sure you'll get errors. But it never hearts to try first without it. If you are wondering why Google Maps API does not need it, it's because they send the KML back to their own servers first. –  CaptDragon Sep 12 '12 at 16:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.