To get the same performance, you need some server-side service to remotely
process and render your KML as, say, a WMS.  I think you may be able to do
that with Mapserver?

MapServer does support KML as a data source, if you compiled with GDAL (which you likely did). It should be very feasible to do this, as follows. (using PHP here)

* Make a program which would accept URLs like this:
   loadkml.php?http://path.to.com/my/stuff.kml

* Have it fetch and save to disk as you imply, simply using file_get_contents() or simply copy(). Probably some sanity checks would be smart here, e.g. check that substr(strtolower(filename),-2)=='.kml' so you can't be tricked into downloading and hosting arbitrary content.

* Run ogrinfo on the KML to find the name and geometry of layer 0. Or use SimpleXML and read the KML to find this info; whichever is easier for you.

* Generate a minimal mapfile: LAYER, DATA, TYPE, and a CLASS depending on the geom type.

* Tell the browser the new WMS service you just created: /cgi-bin/mapserv?map=/temp/kmlmapfiles/123456.map

* Have a callback in the JavaScript which creates a Layer.WMS and adds it to the map.

A significant caveat: MapServer doesn't parse styles from KML, at all, it ignores them and sees only vector features (and only the Name and Description fields at that). So you may need additional steps: load the KML using SimpleXML, iterate over styleUrl entries and then over Placemarks, and generate a custom MapServer CLASS for each Placemark reflecting the styles in the KML.

--
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: [email protected]
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to