[Spanish] Mapas deformados con Openlayers

zepjau orienweb at gmail.com
Sun Nov 18 10:27:21 PST 2012


Gracias.
Te presento el codigo por si puedes ver donde puiede estar el probelma.
Antes comentarte que en qgis georeferencie el mapa y lo reproyecte a wg84
para igualarlo al los datos del gpx.
A continuacion te muestro la funcion de muestra el mapa y cargo el gpx.


function init(){ 

var options = {
	isBaseLayer: true,
        minResolution: "auto",	
        maxResolution: "auto",
	fractionalZoom: true,
        maxExtent: new OpenLayers.Bounds(-5.591515, 37.650752, -5.567809,
37.666971),
	numZoomLevels: 15,
        projection: wgs84Projection,
	displayProjection: wgs84Projection
		};


     
var map = new OpenLayers.Map('map', options );

     map.addControl(new OpenLayers.Control.LayerSwitcher());
     map.addControl(new OpenLayers.Control.MousePosition({displayScale:
true}));
     map.addControl(new OpenLayers.Control.PanZoom());
     map.addControl(new OpenLayers.Control.PanZoomBar());
     map.addControl(new OpenLayers.Control.ScaleLine());
     map.addControl(new OpenLayers.Control.OverviewMap());
     map.addControl(new OpenLayers.Control.KeyboardDefaults());
     map.addControl(new OpenLayers.Control.Attribution());
	

var control = new OpenLayers.Control();
OpenLayers.Util.extend(control, {
    draw: function () {
        this.box = new OpenLayers.Handler.Box( control,
            {"done": this.notice},
            {keyMask: OpenLayers.Handler.MOD_SHIFT});
        this.box.activate();
    },

    notice: function (bounds) {
        OpenLayers.Console.userError(bounds);
    }
});
map.addControl(control);
layer = new OpenLayers.Layer.WMS( "mapa",
"http://localhost/cgi-bin/mapserv?MAP=/var/www/matallana/matallana.map&SERVICE=WMS&MODE=MAP",{srs:'EPSG:4326',
layers: 'matallana1'},{'singleTile':true});

map.addLayers([layer]); 
 
centro = new OpenLayers.LonLat(-5.58403, 37.65552);  //map.getCenter()


var markers = new OpenLayers.Layer.Markers( "Marca" );
map.addLayer(markers);
var size = new OpenLayers.Size(10,10);
var offset = new OpenLayers.Pixel(-(size.w), -size.h);
var icon = new OpenLayers.Icon( "../img/ini.png", size,offset);
markers.addMarker(new OpenLayers.Marker(centro, icon));


var myStyleMap = new OpenLayers.StyleMap({
                 "default": new OpenLayers.Style({
                     pointRadius: 3,
                     fillColor: "green",
                     strokeColor: "red",
                     strokeWidth: 2
                 })
             });
var usuario = "C1";

var lgpx = new OpenLayers.Layer.Vector(usuario, {
                 protocol: new OpenLayers.Protocol.HTTP({
                     url: "matallana.gpx",
                     format: new OpenLayers.Format.GPX({extractWaypoints:
true, extractRoutes: true, extractAttributes: true})
                 }),
                 strategies: [new OpenLayers.Strategy.Fixed()],
		 styleMap: myStyleMap,
                 projection: wgs84Projection  // new
OpenLayers.Projection("EPSG:4326")
             });


map.addLayer(lgpx);
map.setCenter ( centro, 0.1)
map.zoomToExtent(maxExtent)
}

Un saludo,
Javier



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Mapas-deformados-con-Openlayers-tp5016737p5017212.html
Sent from the OSGeo Spanish Local Chapter mailing list archive at Nabble.com.


More information about the Spanish mailing list