Hi,

Also the map units are in meters, doesn't mean that you can measure real
length. EPSG:900913 is not a length-preserving projection. As you can see
that the equator have the same lenght as the north or south pole! With the
OpenLayers measure control you can get probably the correct length.

Arnd

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im
Auftrag von Nicolas Noe
Gesendet: Mittwoch, 25. November 2009 12:01
An: [email protected]
Betreff: [OpenLayers-Users] Distance problem

Hi everyone,

I have a simple problem, bit I can't figure it. I'm probably missing
something very simple and stupid !

I have an OL map with google background. The projection is EPSG:900913, so
the map unit is meters (right?).
I have a marker layer, on which I add a first marker. Then I ask OL to
compute a second marker 1 kilometer on the east, and display it.

It seems to work, except of my distance problem : if I check with the OL
scaleline, there's 1 KM between both markers (which is correct). 
However, if I use the ruler tool of Google Earth, I can see there is only
about 650 meters between these 2 points.

Do you have any idea of where my error is ?
Thanks in advance,

Here is my code :

var BeBounds = new OpenLayers.Bounds(2.5, 49.5, 6.5, 51.5);

function mapInit() {
 
  var map = new OpenLayers.Map('map', {
        projection: new OpenLayers.Projection("EPSG:900913"),
        controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.PanZoomBar(),
                        new
OpenLayers.Control.LayerSwitcher({'ascending':false}),
                        new OpenLayers.Control.Permalink(),
                        new OpenLayers.Control.ScaleLine(),
                        new OpenLayers.Control.Permalink('permalink'),
                        new OpenLayers.Control.MousePosition(),
                        new OpenLayers.Control.OverviewMap(),
                        new OpenLayers.Control.KeyboardDefaults()
                    ]
        });

   var gsat = new OpenLayers.Layer.Google("Google Hybrid",
        {
          type: G_HYBRID_MAP,
          'sphericalMercator':true,
          maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
          /*, numZoomLevels: 20*/ });

  var markers = new OpenLayers.Layer.Markers("Markers");

  map.addLayer(gsat);
  map.addLayer(markers);
 
  // Add a marker
  var myPoint = new OpenLayers.LonLat(5.080646954,50.49373471);
  var myPointInMeters = myPoint.transform(new
OpenLayers.Projection("EPSG:4326"), map.projection);

  var pt2 = myPointInMeters.add(1000,0);

  var mymark  = new OpenLayers.Marker(myPointInMeters);
  var mymark2 = new OpenLayers.Marker(pt2);
 
  markers.addMarker(mymark);
  markers.addMarker(mymark2);

  map.zoomToExtent(BeBounds.transform(new
OpenLayers.Projection("EPSG:4326"), map.projection)); }
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to