Created
March 22, 2013 20:54
-
-
Save sigon426/5224659 to your computer and use it in GitHub Desktop.
Mapa de la cuenca del Duero realizado con OpenGeo y Openlayers, con Google Maps como mapa base y dos capas ríos y embalses.
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>Duero</title> | |
<script src="http://openlayers.org/api/OpenLayers.js"></script> | |
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css"> | |
<style> | |
#map-id { | |
width: 1024px; | |
height: 512px; | |
} | |
.olControlAttribution { | |
font-size: 10px; | |
bottom: 240px; | |
right: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Proyecto Final Cuenca Duero</h1> | |
<div id="map-id"></div> | |
<script | |
src="http://maps.google.com/maps/api/js?v=3.3&sensor=false"> | |
</script> | |
<script> | |
var geographic = new OpenLayers.Projection("EPSG:4326"); | |
var mercator = new OpenLayers.Projection("EPSG:900913"); | |
var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform( | |
geographic, mercator | |
); | |
var center = new OpenLayers.LonLat(-4.72, 41.66).transform( | |
geographic, mercator | |
); | |
var options = { | |
projection: mercator, | |
displayProjection: geographic, | |
units: "m", | |
maxExtent: world, | |
numZoomLevels:6, | |
controls:[ | |
new OpenLayers.Control.LayerSwitcher(), | |
new OpenLayers.Control.PanZoomBar(), | |
] | |
}; | |
var map = new OpenLayers.Map("map-id", options); | |
var satelite = new OpenLayers.Layer.Google( | |
"Google Satélite", {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22} | |
); | |
var embalses= new OpenLayers.Layer.WMS( | |
"embalses", | |
"http://localhost:8080/geoserver/wms", | |
{ | |
layers: "segmentos_embalsepolygon", | |
transparent: true | |
}, | |
{ | |
isBaseLayer: false | |
}, | |
{ | |
} | |
); | |
var rios= new OpenLayers.Layer.WMS( | |
"rios", | |
"http://localhost:8080/geoserver/wms", | |
{ | |
layers: "segmentos_rioline", | |
transparent: true | |
}, | |
{ | |
isBaseLayer: false | |
}, | |
{ | |
} | |
); | |
map.addLayers([satelite,embalses, rios]); | |
//map.setCenter(center, 13); | |
map.addControl(new OpenLayers.Control.MousePosition()); | |
map.addControl(new OpenLayers.Control.LayerSwitcher()); | |
map.zoomToMaxExtent(); | |
map.setCenter(new OpenLayers.LonLat(-5, 42).transform(new OpenLayers.Projection("EPSG:4326"), | |
map.getProjectionObject() | |
), 7); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment