[OpenLayers-Users] Loading kml data into OL

Phil Scadden p.scadden at gns.cri.nz
Sun Mar 20 16:27:25 EDT 2011


I open KMLs like this:

                             layer[i] = new 
OpenLayers.Layer.GML(lay.name, lay.serverUrl, {
                                 format: OpenLayers.Format.KML,
                                 projection: new 
OpenLayers.Projection('EPSG:4326'),
                                 isBaseLayer: false,
                                 formatOptions: {
                                     extractStyles: true,
                                     extractAttributes: true
                                 }
                             })

The "lay" is an object read from JSON file.
The serverURL is the path to kml file, relative to the main file; OR a 
full http: path which needs to be accessible by proxy as XHR is used to 
load it. The configuration works for me whether my main file sits on 
server, or whether its entirely local (though Chrome then wont work).

Server layout is something like
     webapps
                 myapp    (main html/jsp/php lives here)
                             data
                                        kmls
                                                         (kmls live here)


-- 
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, 
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list