I am looking at this example from openlayers themselves. You can see the source by clicking on the "kml-layer.js" link at the bottom. The source code when i do this looks like this:
var map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.WMS(
"WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: "basic"}
),
new OpenLayers.Layer.Vector("KML", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "kml/lines.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true,
maxDepth: 2
})
})
})
],
center: new OpenLayers.LonLat(-112.169, 36.099),
zoom: 11
});
It seems that this will only work if sourcing a kml via HTTP, but what if I want to source it from my own hard drive while I work on the map itself? I can't seem to find much documentation on how to do this, can someone help out?
Thanks
While this functionality requires hosting, there is a small work around. If the data is public, and you don't want to use Python, you can create a free google website, and upload the KML to there and direct a link to it. This used to work for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.