[OpenLayers-Users] Markers and Projections

Pierre GIRAUD bluecarto at gmail.com
Fri Apr 13 10:56:31 EDT 2007


I played around with your sample and found out what was wrong.
I think you couldn't invent but this works if your call
map.zoomToMaxExtent() before you add markers to your layer.

Looking in the code, I could see that the addMarkers method need to
know the current map extent. For a map with a specific projection, the
map.getExtent() method won't return a value till a setCenter, or
zoomTo[..] or whatever is called.

Regards

Pierre

On 4/13/07, david delannoy <david.delannoy at avignon.inra.fr> wrote:
> david delannoy a écrit :
> > 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();
> >
> >
> Does anybody can help me!? I don't find any informations about that
> problem. Which projection do you use with markers? Did you have any
> problems with markers on any projection? I'm new in OpenLayers and maybe
> I made a big mistake.
>
> Please advice.
> Thank you in advance,
> Bye
> David
>
>
> --
> David DELANNOY
> Ingénieur en Bioinformatique
> Unité Agroclim
> Site Agroparc
> INRA AVIGNON
> david.delannoy at avignon.inra.fr
> 04 32 72 24 13
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list