Skip to content

Instantly share code, notes, and snippets.

@yjacolin
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjacolin/11340324 to your computer and use it in GitHub Desktop.
Save yjacolin/11340324 to your computer and use it in GitHub Desktop.
OSM and KML layers with OpenLayers
<html>
<head>
<title>Example OpenLayers avec une couche KML sur fond de plan KML</title>
<script
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer='defer' type='text/javascript'>
var map = new OpenLayers.Map('map', {
maxExtent: new OpenLayers.Bounds(-2209947.3614731,4806360.337903,2447207.8972378,7059112.4352102)
});
var layer = new OpenLayers.Layer.OSM({
sphericalMercator: true,
maxExtent: new OpenLayers.Bounds(-2209947.3614731,4806360.337903,2447207.8972378,7059112.4352102)
});
var couche3 = new OpenLayers.Layer.Vector("Gontran", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "job_region.kml",
format: new OpenLayers.Format.KML({
extractAttributes: true, extractStyles: true
})
})
});
map.addLayers([layer, couche3]);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':true}));
map.addControl(scaleline);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment