Guest User

js-test

a guest
Feb 14th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var map;
  3.  
  4. function init() {
  5.  
  6.     var corunha = new OpenLayers.Projection("EPSG:23029");
  7.     var mercator = new OpenLayers.Projection("EPSG:900913");
  8.     var geographic = new OpenLayers.Projection("EPSG:4326");
  9.     var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(geographic, mercator);
  10.  
  11.     var options = {
  12.         projection: mercator,
  13.         units: "m",
  14.         maxExtent: world
  15.     };
  16.     map = new OpenLayers.Map('map', options);
  17.  
  18.     var osm = new OpenLayers.Layer.OSM();
  19.  
  20.     var wms = new OpenLayers.Layer.WMS(
  21.         "Carreteras",
  22.         "http://localhost:8080/geoserver/wms",
  23.         {'layers': "corunha:carreteras", 'format':'image/png', 'transparent':'true'},
  24.         {'opacity': 1.0, 'isBaseLayer': false, 'visibility': true}
  25.     );
  26.  
  27.     OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
  28.     var wfs = new OpenLayers.Layer.Vector(
  29.         "Centros acceso internet (WFS)",
  30.         {strategies: [new OpenLayers.Strategy.BBOX()],
  31.          protocol: new OpenLayers.Protocol.WFS({
  32.              url: "http://localhost:8080/geoserver/wfs",
  33.              featurePrefix: "corunha",
  34.              featureType: "centros_acceso_internet",
  35.              geometryName: "geometria",
  36.              srsName: "EPSG:23029",
  37.              version: "1.1.0"}),
  38.          projection: corunha
  39.         }
  40.     );
  41.  
  42.     //Add layers
  43.     map.addLayers([osm, wfs, wms]);
  44.  
  45.     map.addControl(new OpenLayers.Control.LayerSwitcher());
  46.  
  47.     var finisterre = new OpenLayers.LonLat(-9.23, 42.92).transform(geographic, map.getProjectionObject());
  48.     map.setCenter(finisterre, 10);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment