[OpenLayers-Users] Proj4js and IE

Pierre GIRAUD bluecarto at gmail.com
Fri Jun 20 10:00:03 EDT 2008


This is the code working for me.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <style type="text/css">
        .olControlAttribution { bottom: 0px!important }
        #map {
            height: 512px;
        }
    </style>


    <script src="../lib/OpenLayers.js"></script>
    <script src="http://svn.codehaus.org/mapbuilder/cscs/trunk/proj4js/lib/proj4js-compressed.js"></script>

    <script type="text/javascript">

        // make map available for easy debugging
        var map, layer;

        // avoid pink tiles
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
        OpenLayers.Util.onImageLoadErrorColor = "transparent";

        function init(){

            Proj4js.defs["EPSG:27582"] = "+proj=lcc +lat_1=46.8
+lat_0=46.8 +lon_0=-2.33722917 +k_0=0.99987742 +x_0=600000
+y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0
+pm=paris +units=m +no_defs";

            var pop = new OpenLayers.Projection('EPSG:4326');
            var dpop = new OpenLayers.Projection('EPSG:27582');
            var extent = new OpenLayers.Bounds(-5,40,8,52 );
            var options = {
                theme: null,
                maxResolution:'auto',
                maxExtent: extent,
                numZoomLevels:12,
                controls:[],
                projection: pop,
                displayProjection: dpop,
                units:"m"
            };
            map = new OpenLayers.Map('map',options);


            // create WMS layer
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://labs.metacarta.com/wms/vmap0",
                    {layers: 'basic'} );
            map.addLayers([layer]);

            map.addControl(new OpenLayers.Control.MousePosition());
            if (!map.getCenter()) {map.zoomToMaxExtent()}
        }

    </script>
  </head>
  <body onload="init()">
    <h1 id="title">OpenLayers displayProjection Example</h1>
    <div id="map" class="smallmap"></div>

    <div id="docs">
    </div>
  </body>
</html>

Hope this helps.

On Fri, Jun 20, 2008 at 3:53 PM, Damien Lécole <damien.lecole at gmail.com> wrote:
> Hi Pierre,
>
> Thanks for help. Unfortunately my code is too long  to be posted here. I
> have also tried with only basic code as following :
>
> function initialisation()
> {
>
>     ////////////////////////////////////////////// initialisation des
> options pour la carte
>     var longi = 2.3;
>     var lati = 48.7;
>     var lonlat = new OpenLayers.LonLat(longi,lati);
>     var zoom = 2;
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>     ///////////////////////////////////////////////////////////////////
> création de la carte
>
>     var extent = new OpenLayers.Bounds(-5,40,8,52 );
>     var pop = new OpenLayers.Projection('EPSG:4326');
>     var dpop = new OpenLayers.Projection('EPSG:27582');
>     var options = {theme: null,  maxResolution:'auto', maxExtent: extent,
> numZoomLevels:20, projection: pop, displayProjection: dpop,controls:[]};
>     map = new OpenLayers.Map('map',options);
>
>     ///////////////////////////////////////// création et ajout des layers a
> la carte
>     var geosignal_wms = new OpenLayers.Layer.WMS( "Plans de
> ville","http://www.geosignal.org/cgi-bin/wmsmap?",{layers:
> 'RASTER1000K,RASTER500K,RASTER250K,RASTER100K,RASTER50K,RASTER25K,RASTER5K'});
>     map.addLayer(geosignal_wms);
>
>     // création des controls
>     var mouse = new OpenLayers.Control.MousePosition();
>     map.addControl(mouse);
>     map.addControl(new OpenLayers.Control.Navigation());
>     map.setCenter(lonlat, zoom,false,false);
> }
>
>
> and the result is still the same. Maybe the map.setCenter() function or the
> initialisation of the variables longi, lati or extent get some issues...
>
>
>
>
> 2008/6/20 Pierre GIRAUD <bluecarto at gmail.com>:
>>
>> I just add a try in both IE6 and IE7 and it seems like it worked well for
>> me.
>>
>> Can you give us more code so that we can test it in the same context as
>> yours ?
>>
>> Regards,
>> Pierre
>>
>> On Fri, Jun 20, 2008 at 11:45 AM, Damien Lécole <damien.lecole at gmail.com>
>> wrote:
>> >
>> > Hi list,
>> >
>> > I have a map in EPSG:4326. I would like the coordinates displayed by my
>> > Control.MousePosition in EPSG:27582. So I am using Proj4js and I have
>> > written the following code :
>> >
>> >
>> > var pop = new OpenLayers.Projection('EPSG:4326');
>> > var dpop = new OpenLayers.Projection('EPSG:27582');
>> > var extent = new OpenLayers.Bounds(-5,40,8,52 );
>> > var options = {theme: null,  maxResolution:'auto', maxExtent: extent,
>> > numZoomLevels:12, controls:[], projection: pop, displayProjection: dpop,
>> > units:"m"};
>> > map = new OpenLayers.Map('map',options);
>> >
>> > This works fine with Firefox but not with Internet Explorer :
>> > coordinates
>> > are still in EPSG:4326. Am I missing something? Thanks.
>> >
>> > Regards,
>> > Damien Lécole
>> > --
>> > View this message in context:
>> > http://www.nabble.com/Proj4js-and-IE-tp18025067p18025067.html
>> > Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> >
>> > _______________________________________________
>> > Users mailing list
>> > Users at openlayers.org
>> > http://openlayers.org/mailman/listinfo/users
>> >
>
>



More information about the Users mailing list