[OpenLayers-Users] Markers and Projections

david delannoy david.delannoy at avignon.inra.fr
Fri Apr 13 11:21:13 EDT 2007


Cicconetti, Bob a écrit :
> See:
> http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#Projections
>
> If all of your data is in EPSG:27582, it would be easier to just set the projection in your map object, and don't hardcode the epsg code in your WMS url. For example, I use 26985:
>
>   var map = new OpenLayers.Map("map", 
>   	{maxExtent: new OpenLayers.Bounds(397000, 112000, 469000, 179000), 
> 	units: "m",
> 	projection: "EPSG:26985",
> 	tileSize: new OpenLayers.Size(512,512)
> 	});
>
>   var layer = new OpenLayers.Layer.WMS( "Spring 05 0.5ft", 
>               "http://cac0076568/cgi-bin/mapserv.exe?map=/aac1.map",
> 	      {layers: 'AACo_2005_0.5ft_Spring' },
> 	      {isBaseLayer: true});
>   map.addLayer(layer);
>
> -----Original Message-----
> From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On Behalf Of david delannoy
> Sent: Friday, April 13, 2007 9:22 AM
> To: users at openlayers.org
> Subject: [OpenLayers-Users] Markers and Projections
>
> Hello,
>
> I'm trying to display markers on a map wich display a layer in 
> projection 27582. It seems that it doesn't work while it works for the 
> projection 4269. Here is a part of my code.
> Thank in advance for your help.
>
>        var llon = 658500;
>        var llat = 2380000;
>
>        var options = {
>                   maxResolution: "auto",
>
>                   /* maxExtent is the maximum bounds, in the units of 
> your map,
>                   of the plane in which you want to display information */
>                   maxExtent: new 
> OpenLayers.Bounds(50000,1586013,1160964,2771788),
>                   /* maxExtent is the minimum bounds, in the units of 
> your map,
>                   of the plane in which you want to display information */
>                   minExtent: new 
> OpenLayers.Bounds(50000,1586013,1160964,2771788),
>                   /* Number of zoom levels */
>                   numZoomLevels: 4,
>                   /* Unit of geographical values on the map */
>                   units : "meters"
>                 };
>
>           var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
>               "http://www.geosignal.org/cgi-bin/wmsmap?SRS=EPSG:27582&",
>           {layers: 'RASTER1000k',transparent: "false", format: 
> "image/png"}, options);
>           map.addLayer(ol_wms);
>                     /* Ajout de markers */
>           var markers = new OpenLayers.Layer.Markers( "Markers" );
>           map.addLayer(markers);
>
>           var size = new OpenLayers.Size(20,30);
>           var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
>           var icon = new 
> OpenLayers.Icon('http://boston.openguides.org/markers/RED.png',size,offset); 
>
>           var marker = new OpenLayers.Marker(new 
> OpenLayers.LonLat(llon,llat),icon);
>           markers.addMarker(marker);
>           marker.events.register('mousedown', marker, function(evt) { 
> alert(this.icon.url); Event.stop(evt); });
>
>           map.addControl(new OpenLayers.Control.LayerSwitcher());
>           map.zoomToMaxExtent();
>
>   
You're good!!! It works well now. Thank you very much!

-- 
David DELANNOY
Ingénieur en Bioinformatique
Unité Agroclim
Site Agroparc
INRA AVIGNON
david.delannoy at avignon.inra.fr
04 32 72 24 13




More information about the Users mailing list