Last active
August 29, 2015 14:00
-
-
Save yjacolin/11340324 to your computer and use it in GitHub Desktop.
OSM and KML layers with OpenLayers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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