Widget:Levävahti
<script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/OpenLayers.js"></script> <script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/lib/OpenLayers/Lang/fi.js"></script> <script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/lib/OpenLayers/Lang/sv-SE.js"></script> <script type="text/javascript"> function _init() {
var map; var epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection var mapProjStr = "3857"; var projectTo = new OpenLayers.Projection("EPSG:" + mapProjStr); //The map projection
//map object var options = {
projection: "EPSG:" + mapProjStr,
units: "m", controls: [ new OpenLayers.Control.Navigation({zoomWheelEnabled : false}), new OpenLayers.Control.Zoom(), new OpenLayers.Control.LayerSwitcher({'ascending':false}), new OpenLayers.Control.Attribution() ] };
map = new OpenLayers.Map( , options );
//OpenStreetMap osm = new OpenLayers.Layer.OSM("OpenStreetMap", null, {
sphericalMercator: true, projection: projectTo, transitionEffect: "resize", attribution: "© <a href='//www.openstreetmap.org/copyright'>OpenStreetMapin tekijät</a>"
});
map.addLayer(osm);
kml = new OpenLayers.Layer.Vector("KML", {
strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "/kml/levavahti.php?type=sinileva&day=2012-01-01&day2=2013-06-06", format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true, maxDepth: 2 }) }) });
map.addLayer(kml);
var lonMin = 20;
var lonMax = 30; var latMin = 60; var latMax = 70;
bounds = new OpenLayers.Bounds(); bounds.extend(new OpenLayers.LonLat(lonMin,latMin).transform(epsg4326, projectTo)); bounds.extend(new OpenLayers.LonLat(lonMax,latMax).transform(epsg4326, projectTo)); map.zoomToExtent(bounds);
}
_init();
</script>