<p class="MsoNormal"><span lang="EN-US">In Sweden
we are using RT90 (</span><a href="http://spatialreference.org/ref/epsg/3021/"><span lang="EN-US">http://spatialreference.org/ref/epsg/3021/</span></a><span lang="EN-US">). I’ve been working on a app that
displays EPSG:3021-coords upon Google Maps (EPSG:900913). (I got help by Erik
Hazzard, the author of the book Openalyers 2.10).</span></p>

<p class="MsoNormal"><span lang="EN-US">It’s almost
working, but there is still one thing that’s kind of odd which neither he nor I
understand.</span></p>

<p class="MsoNormal"><span lang="EN-US">See Code
below</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">&lt;!DOCTYPE
html&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">&lt;html&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;head&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;meta
http-equiv=&quot;Content-Type&quot; content=&quot;text/html;
charset=utf-8&quot;&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;meta name=&quot;viewport&quot;
content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0,
user-scalable=0&quot;&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;meta
name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">        &lt;link rel=&quot;stylesheet&quot;
href=&quot;<a href="http://openlayers.org/dev/theme/default/style.css">http://openlayers.org/dev/theme/default/style.css</a>&quot;
type=&quot;text/css&quot;&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">        &lt;link rel=&quot;stylesheet&quot;
href=&quot;<a href="http://openlayers.org/dev/examples/style.css">http://openlayers.org/dev/examples/style.css</a>&quot; type=&quot;text/css&quot;&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">        &lt;style&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">           .olControlMousePosition {</span></p>

<p class="MsoNormal"><span lang="EN-US">                background:rgba(255,255,255,.9)
!important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                </span>border:1px solid
rgba(0,0,0,.4) !important;</p>

<p class="MsoNormal">                <span lang="EN-US">bottom:150px !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                font-size:1em !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                font-weight:bold !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                padding:2px !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                position:absolute !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                right:2px !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">                width:100px !important;</span></p>

<p class="MsoNormal"><span lang="EN-US">            }</span></p>

<p class="MsoNormal"><span lang="EN-US">        &lt;/style&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;/head&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;body&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;div id=&quot;map&quot;
style=&#39;height:500px;width:500px;&#39;&gt;&lt;/div&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;div id=&#39;point_display&#39;&gt;&lt;/div&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">&lt;script
src=&quot;<a href="http://openlayers.org/dev/OpenLayers.js">http://openlayers.org/dev/OpenLayers.js</a>&quot;&gt;&lt;/script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US"> &lt;script src=&#39;proj4js.js&#39;&gt;&lt;/script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">&lt;script
src=&quot;<a href="http://maps.googleapis.com/maps/api/js?v=3.5&amp;amp;sensor=false">http://maps.googleapis.com/maps/api/js?v=3.5&amp;amp;sensor=false</a>&quot;&gt;&lt;/script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;script
src=&quot;EPSG3021.js&quot;&gt;&lt;/script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">        var map = new OpenLayers.Map({</span></p>

<p class="MsoNormal"><span lang="EN-US">            div: &quot;map&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">            projection: new
OpenLayers.Projection(&#39;EPSG:900913&#39;),</span></p>

<p class="MsoNormal"><span lang="EN-US">            displayProjection: new
OpenLayers.Projection(&#39;EPSG:3021&#39;)</span></p>

<p class="MsoNormal"><span lang="EN-US">        });</span></p>

<p class="MsoNormal"><span lang="EN-US">//*********************************                                                     </span></p>

<p class="MsoNormal"><span lang="EN-US">       var google_hybrid = new
OpenLayers.Layer.Google(</span></p>

<p class="MsoNormal"><span lang="EN-US">                &quot;Google Hybrid&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">                {sphericalMercator: true,type:
google.maps.MapTypeId.HYBRID, numZoomLevels: 22}</span></p>

<p class="MsoNormal"><span lang="EN-US">            );</span></p>

<p class="MsoNormal"><span lang="EN-US">      var google_physical = new
OpenLayers.Layer.Google(</span></p>

<p class="MsoNormal"><span lang="EN-US">                &quot;Google Physical&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">                {sphericalMercator: true,type:
google.maps.MapTypeId.TERRAIN, numZoomLevels: 22}</span></p>

<p class="MsoNormal"><span lang="EN-US">            );</span></p>

<p class="MsoNormal"><span lang="EN-US">      var google_satellite = new
OpenLayers.Layer.Google(</span></p>

<p class="MsoNormal"><span lang="EN-US">                &quot;Google Satellite&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">                {sphericalMercator: true,type:
google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}</span></p>

<p class="MsoNormal"><span lang="EN-US">            );</span></p>

<p class="MsoNormal"><span lang="EN-US">       var google_streets = new
OpenLayers.Layer.Google(</span></p>

<p class="MsoNormal"><span lang="EN-US">                &quot;Google Streets&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">                {sphericalMercator:
true,numZoomLevels: 22}</span></p>

<p class="MsoNormal"><span lang="EN-US">            );                                                                                                     </span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">//******************************                                                                                          </span></p>

<p class="MsoNormal"><span lang="EN-US">       var
vector_layer = new OpenLayers.Layer.Vector(</span></p>

<p class="MsoNormal"><span lang="EN-US">            &#39;Vector Layer&#39;,</span></p>

<p class="MsoNormal"><span lang="EN-US">            {</span></p>

<p class="MsoNormal"><span lang="EN-US">                strategies: [new
OpenLayers.Strategy.Fixed()],</span></p>

<p class="MsoNormal"><span lang="EN-US">                projection: new
OpenLayers.Projection(&#39;EPSG:3021&#39;),</span></p>

<p class="MsoNormal"><span lang="EN-US">                protocol: new
OpenLayers.Protocol.HTTP({</span></p>

<p class="MsoNormal"><span lang="EN-US">                    url: &quot;data_in_3021.json&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">                    format: new
OpenLayers.Format.GeoJSON({</span></p>

<p class="MsoNormal"><span lang="EN-US">                    })</span></p>

<p class="MsoNormal"><span lang="EN-US">                })</span></p>

<p class="MsoNormal"><span lang="EN-US">        });</span></p>

<p class="MsoNormal"><span lang="EN-US">       
vector_layer.events.register(&#39;featureselected&#39;, this, function(feature){</span></p>

<p class="MsoNormal"><span lang="EN-US">            var feature_html = &#39;&#39;;</span></p>

<p class="MsoNormal"><span lang="EN-US">            var feature_copy =
feature.feature.clone();</span></p>

<p class="MsoNormal"><span lang="EN-US">            var feature_reprojected =  feature_copy.geometry.transform(</span></p>

<p class="MsoNormal"><span lang="EN-US">                new
OpenLayers.Projection(&#39;EPSG:900913&#39;),</span></p>

<p class="MsoNormal"><span lang="EN-US">                new
OpenLayers.Projection(&#39;EPSG:3021&#39;));</span></p>

<p class="MsoNormal"><span lang="EN-US">            feature_html += &quot;Lon: &quot; +
feature_reprojected.x</span></p>

<p class="MsoNormal"><span lang="EN-US">                + &quot; | Lat: &quot; +
feature_reprojected.y;</span></p>

<p class="MsoNormal"><span lang="EN-US">            feature_html += &quot; | Antal:
&quot; + feature_copy.attributes.observations_count;</span></p>

<p class="MsoNormal"><span lang="EN-US">            feature_html += &quot;&lt;br
/&gt;&quot;;</span></p>

<p class="MsoNormal"><span lang="EN-US">            document.getElementById(&#39;point_display&#39;).innerHTML
+= feature_html;</span></p>

<p class="MsoNormal"><span lang="EN-US">        });</span></p>

<p class="MsoNormal"><span lang="EN-US">       
vector_layer.events.register(&#39;featureunselected&#39;, this,
function(feature){</span></p>

<p class="MsoNormal"><span lang="EN-US">           
document.getElementById(&#39;point_display&#39;).innerHTML = &#39;&#39;;</span></p>

<p class="MsoNormal"><span lang="EN-US">        });</span></p>

<p class="MsoNormal"><span lang="EN-US">        map.addLayers([</span></p>

<p class="MsoNormal"><span lang="EN-US">        google_hybrid, </span>google_physical, google_satellite, google_streets, vector_layer</p>

<p class="MsoNormal"><span lang="EN-US">        ]);</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">        //-------------------------------</span></p>

<p class="MsoNormal"><span lang="EN-US">        //Controls</span></p>

<p class="MsoNormal"><span lang="EN-US">        //-------------------------------</span></p>

<p class="MsoNormal"><span lang="EN-US">        var overview_map = new
OpenLayers.Control.OverviewMap(</span></p>

<p class="MsoNormal"><span lang="EN-US">            {</span> autoPan: true, <span lang="EN-US">size: new
OpenLayers.Size(150,100)</span> }</p>

<p class="MsoNormal"><span lang="EN-US">        );</span></p>

<p class="MsoNormal"><span lang="EN-US">        var select_features_control = new
OpenLayers.Control.SelectFeature(</span></p>

<p class="MsoNormal"><span lang="EN-US">            vector_layer,{</span></p>

<p class="MsoNormal"><span lang="EN-US">                clickout: true,</span></p>

<p class="MsoNormal"><span lang="EN-US">                toggle: false,</span></p>

<p class="MsoNormal"><span lang="EN-US">                multiple: true,</span></p>

<p class="MsoNormal"><span lang="EN-US">                hover: false,</span></p>

<p class="MsoNormal"><span lang="EN-US">                box: true</span></p>

<p class="MsoNormal"><span lang="EN-US">        });</span></p>

<p class="MsoNormal"><span lang="EN-US">        map.addControls([</span></p>

<p class="MsoNormal"><span lang="EN-US">            new OpenLayers.Control.MousePosition(),</span></p>

<p class="MsoNormal"><span lang="EN-US">            new
OpenLayers.Control.LayerSwitcher(),</span></p>

<p class="MsoNormal"><span lang="EN-US">            overview_map,</span></p>

<p class="MsoNormal"><span lang="EN-US">            select_features_control</span></p>

<p class="MsoNormal"><span lang="EN-US">        ]);</span></p>

<p class="MsoNormal"><span lang="EN-US">        overview_map.maximizeControl();</span></p>

<p class="MsoNormal"><span lang="EN-US">        select_features_control.activate();</span></p>

<p class="MsoNormal"><span lang="EN-US">        if(!map.getCenter()){</span></p>

<p class="MsoNormal"><span lang="EN-US">            map.setCenter(</span></p>

<p class="MsoNormal"><span lang="EN-US">                new OpenLayers.LonLat(1738182,
9069017),</span></p>

<p class="MsoNormal"><span lang="EN-US">                6);</span></p>

<p class="MsoNormal"><span lang="EN-US">        }</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;/script&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">    &lt;/body&gt;</span></p>

<p class="MsoNormal"><span lang="EN-US">&lt;/html&gt;</span></p><p class="MsoNormal"><span lang="EN-US"><br></span></p>

<p class="MsoNormal"><span lang="EN-US">The
JSON-file contains:</span></p>

<p class="MsoNormal"><span lang="EN-US">{&quot;type&quot;:
&quot;FeatureCollection&quot;, &quot;features&quot;: [</span></p>

<p class="MsoNormal"><span lang="EN-US">                             {&quot;type&quot;:&quot;Feature&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">   
&quot;geometry&quot;:{&quot;type&quot;:&quot;Point&quot;,</span></p>

<p class="MsoNormal"><span lang="EN-US">    &quot;coordinates&quot;:[1710943,
7456832]},</span></p>

<p class="MsoNormal"><span lang="EN-US">   
&quot;properties&quot;:{&quot;observations_count&quot;: 1 }}</span></p>

<p class="MsoNormal"><span lang="EN-US">]}</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">This
geolocation, 1710943, 7456832 is a well known roundabout in my hometown and when
the marker hits the map it’s placed some 400 m Northbound and 200 meters
Eastbound from where it should be. Looking at the map.</span></p>

<p class="MsoNormal"><span lang="EN-US">When I move
the mouse over the actual marker it displays the correct locations as above.</span></p>

<p class="MsoNormal"><span lang="EN-US">If I move
the mouse to where it should be, it displays the wrong lon-lat-coordinates.</span></p>

<p class="MsoNormal"><span lang="EN-US">I used to
work with ARC-GIS before and this gives me thoughts about the layers not being properly
rectified to each other</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">I’d
appreciate it a lot if somebody could give me a hint on where to look and what
to correct.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Best
regards</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Roger Waara</span></p>

<p class="MsoNormal"><span lang="EN-US">Sweden</span></p><div><br></div>-- <br><br>=========================<br>Roger Waara<br>