# Incorrect Distances / Scales

**URL:** <https://community.thinkgeo.com/t/incorrect-distances-scales/5427>\
**Category:** WebForms\
**Created:** [August 4, 2010, 10:43am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427 "2010-08-04T10:43:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@Gary1](https://community.thinkgeo.com/u/Gary1)\
**Post date:** [August 4, 2010, 10:43am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/1 "2010-08-04T10:43:27Z")

</div>

Hi,

I'm&nbsp;having&nbsp;a&nbsp;problem&nbsp;with&nbsp;distances,&nbsp;which&nbsp;seems&nbsp;to&nbsp;be&nbsp;manifesting&nbsp;itself&nbsp;in&nbsp;two&nbsp;ways&nbsp;but&nbsp;probably&nbsp;has&nbsp;the&nbsp;same&nbsp;root&nbsp;cause.

Firstly,&nbsp;the&nbsp;scale&nbsp;shown&nbsp;on&nbsp;the&nbsp;maps&nbsp;doesn't&nbsp;seem&nbsp;to&nbsp;be&nbsp;correct.&nbsp;As&nbsp;an&nbsp;example,&nbsp;I've&nbsp;attached&nbsp;a&nbsp;couple&nbsp;of&nbsp;screenshots.&nbsp;The&nbsp;first&nbsp;shows&nbsp;an&nbsp;airport&nbsp;feature&nbsp;on&nbsp;a&nbsp;raster&nbsp;Virtual&nbsp;Earth&nbsp;map&nbsp;from&nbsp;maps.live.com.

 ![](https://community.thinkgeo.com/uploads/default/original/1X/eb74b54f46985d52d2c9777a0e032201e3169f43.png)

Here,&nbsp;you&nbsp;can&nbsp;see&nbsp;the&nbsp;main&nbsp;runway&nbsp;is&nbsp;approximate&nbsp;2km&nbsp;long.

The&nbsp;second&nbsp;screenshot&nbsp;shows&nbsp;the&nbsp;same&nbsp;feature&nbsp;in&nbsp;Virtual&nbsp;Earth,&nbsp;but&nbsp;this&nbsp;time&nbsp;loaded&nbsp;within&nbsp;Map&nbsp;Suite.

 ![](https://community.thinkgeo.com/uploads/default/original/1X/aa4dc01e975eb3a9a5888140ed9c30285d755a3a.png)

I&nbsp;know&nbsp;the&nbsp;tiles&nbsp;look&nbsp;slightly&nbsp;different&nbsp;(because&nbsp;MS&nbsp;have&nbsp;recently&nbsp;updated&nbsp;the&nbsp;images&nbsp;on&nbsp;maps.live.com),&nbsp;but&nbsp;the&nbsp;airport&nbsp;feature&nbsp;is&nbsp;the&nbsp;same&nbsp;size&nbsp;which&nbsp;indicates&nbsp;they&nbsp;are&nbsp;at&nbsp;the&nbsp;same&nbsp;logical&nbsp;scale&nbsp;(I've&nbsp;confirmed&nbsp;this&nbsp;with&nbsp;other&nbsp;roads/features&nbsp;as&nbsp;well).&nbsp;The&nbsp;scale&nbsp;bar&nbsp;in&nbsp;Map&nbsp;Suite&nbsp;however,&nbsp;now&nbsp;implies&nbsp;the&nbsp;main&nbsp;runway&nbsp;is&nbsp;about&nbsp;3km&nbsp;long.

The&nbsp;second&nbsp;manifestion&nbsp;of&nbsp;the&nbsp;issue&nbsp;is&nbsp;when&nbsp;I'm&nbsp;rendering&nbsp;circles&nbsp;that&nbsp;have&nbsp;been&nbsp;stored&nbsp;with&nbsp;a&nbsp;central&nbsp;lat/lon&nbsp;and&nbsp;a&nbsp;radius&nbsp;in&nbsp;metres.&nbsp;These&nbsp;are&nbsp;now&nbsp;being&nbsp;rendered&nbsp;smaller&nbsp;in&nbsp;Map&nbsp;Suite&nbsp;that&nbsp;they&nbsp;used&nbsp;to&nbsp;be&nbsp;when&nbsp;we&nbsp;used&nbsp;a&nbsp;different&nbsp;3rd&nbsp;party&nbsp;component,&nbsp;which&nbsp;is&nbsp;consistent&nbsp;with&nbsp;the&nbsp;behaviour&nbsp;described&nbsp;above&nbsp;(i.e.&nbsp;Map&nbsp;Suite&nbsp;thinks&nbsp;a&nbsp;given&nbsp;distance&nbsp;is&nbsp;smaller&nbsp;than&nbsp;it&nbsp;actually&nbsp;is).

Is&nbsp;this&nbsp;a&nbsp;problem&nbsp;in&nbsp;the&nbsp;component,&nbsp;or&nbsp;a&nbsp;misunderstanding&nbsp;on&nbsp;my&nbsp;part&nbsp;in&nbsp;the&nbsp;way&nbsp;I'm&nbsp;using&nbsp;it?&nbsp;All&nbsp;of&nbsp;the&nbsp;maps&nbsp;we're&nbsp;displaying&nbsp;are&nbsp;spherical&nbsp;Mercator,&nbsp;and&nbsp;the&nbsp;map&nbsp;units&nbsp;are&nbsp;set&nbsp;to&nbsp;metres.&nbsp;We're&nbsp;not&nbsp;seeing&nbsp;any&nbsp;issues&nbsp;with&nbsp;lat/lon&nbsp;positioning&nbsp;-&nbsp;just&nbsp;these&nbsp;problems&nbsp;with&nbsp;distances.&nbsp;I'm&nbsp;just&nbsp;using&nbsp;the&nbsp;standard&nbsp;ZoomLevels&nbsp;(1-20),&nbsp;not&nbsp;custom&nbsp;ones.

Best&nbsp;regards,

Gary

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 5, 2010, 11:10am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/2 "2010-08-05T11:10:19Z")

</div>

I&nbsp;find&nbsp;strange&nbsp;that&nbsp;you&nbsp;have&nbsp;the&nbsp;scale&nbsp;bar&nbsp;displaying&nbsp;incorrectly&nbsp;if&nbsp;you&nbsp;have&nbsp;the&nbsp;MapUnit&nbsp;of&nbsp;your&nbsp;map&nbsp;set&nbsp;to&nbsp;meter&nbsp;as&nbsp;it&nbsp;should&nbsp;be&nbsp;using&nbsp;Virtual&nbsp;Earth.&nbsp;Can&nbsp;you&nbsp;tell&nbsp;what&nbsp;the&nbsp;extent&nbsp;of&nbsp;the&nbsp;map&nbsp;is&nbsp;where&nbsp;you&nbsp;are&nbsp;zoomed&nbsp;in&nbsp;to&nbsp;the&nbsp;airport?&nbsp;I&nbsp;would&nbsp;like&nbsp;to&nbsp;test&nbsp;on&nbsp;my&nbsp;own&nbsp;with&nbsp;scalebar&nbsp;on&nbsp;that&nbsp;part&nbsp;of&nbsp;the&nbsp;map&nbsp;but&nbsp;I&nbsp;don’t&nbsp;know&nbsp;where&nbsp;that&nbsp;airport&nbsp;is&nbsp;located.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Gary1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@Gary1](https://community.thinkgeo.com/u/Gary1)\
**Post date:** [August 5, 2010, 11:21am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/3 "2010-08-05T11:21:55Z")

</div>

Hi&nbsp;Val,&nbsp;  
&nbsp;&nbsp;  
&nbsp;That&nbsp;particular&nbsp;airport&nbsp;is&nbsp;at:&nbsp;  
&nbsp;&nbsp;  
&nbsp;Lat:&nbsp;53.771899&nbsp;  
&nbsp;Lon:&nbsp;-3.032999&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’ve&nbsp;done&nbsp;the&nbsp;same&nbsp;check&nbsp;with&nbsp;different&nbsp;areas&nbsp;throughout&nbsp;the&nbsp;UK&nbsp;though&nbsp;-&nbsp;I&nbsp;just&nbsp;used&nbsp;this&nbsp;one&nbsp;as&nbsp;the&nbsp;horizontal&nbsp;runway&nbsp;demonstrated&nbsp;the&nbsp;issue&nbsp;quite&nbsp;well.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’ve&nbsp;also&nbsp;just&nbsp;double&nbsp;checked&nbsp;and&nbsp;I’m&nbsp;definitely&nbsp;using&nbsp;mapControl.MapUnit&nbsp;=&nbsp;GeographyUnit.Meter.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Best&nbsp;regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary&nbsp;

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 5, 2010, 3:51pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/4 "2010-08-05T15:51:49Z")

</div>

I&nbsp;think&nbsp;I&nbsp;know&nbsp;what&nbsp;is&nbsp;going&nbsp;on.&nbsp;The&nbsp;scale&nbsp;bar&nbsp;is&nbsp;based&nbsp;on&nbsp;the&nbsp;coordinates&nbsp;of&nbsp;the&nbsp;Mercator&nbsp;projection&nbsp;which&nbsp;is&nbsp;a&nbsp;projection&nbsp;that&nbsp;grossly&nbsp;exagerates&nbsp;the&nbsp;distances&nbsp;at&nbsp;high&nbsp;latitudes.&nbsp;(see&nbsp;the&nbsp;article&nbsp;on&nbsp;Mercator&nbsp;projection:&nbsp;[en.wikipedia.org/wiki/Mercator\_projection](http://en.wikipedia.org/wiki/Mercator_projection)

&nbsp;Since,&nbsp;your&nbsp;airport&nbsp;is&nbsp;at&nbsp;a&nbsp;fairly&nbsp;high&nbsp;latitude&nbsp;in&nbsp;the&nbsp;UK,&nbsp;the&nbsp;Scale&nbsp;Bar&nbsp;seems&nbsp;to&nbsp;show&nbsp;an&nbsp;exagerated&nbsp;distance&nbsp;although&nbsp;it&nbsp;is&nbsp;calculated&nbsp;correctly&nbsp;based&nbsp;on&nbsp;the&nbsp;coordinates&nbsp;of&nbsp;the&nbsp;Mercator&nbsp;projection&nbsp;that&nbsp;are&nbsp;in&nbsp;meters.&nbsp;To&nbsp;correct&nbsp;that,&nbsp;we&nbsp;would&nbsp;have&nbsp;to&nbsp;have&nbsp;the&nbsp;scale&nbsp;bar&nbsp;based&nbsp;on&nbsp;a&nbsp;local&nbsp;projection&nbsp;and&nbsp;not&nbsp;on&nbsp;the&nbsp;Mercator&nbsp;projection.&nbsp;We&nbsp;can&nbsp;work&nbsp;on&nbsp;creating&nbsp;a&nbsp;Scale&nbsp;bar&nbsp;on&nbsp;a&nbsp;projection&nbsp;different&nbsp;from&nbsp;the&nbsp;Map&nbsp;Projection.&nbsp;What&nbsp;projection&nbsp;would&nbsp;you&nbsp;like&nbsp;us&nbsp;to&nbsp;use?&nbsp;UTM&nbsp;or&nbsp;some&nbsp;other&nbsp;UK&nbsp;projection.&nbsp;Keep&nbsp;in&nbsp;mind&nbsp;that&nbsp;with&nbsp;a&nbsp;custom&nbsp;Scale&nbsp;bar,&nbsp;it&nbsp;going&nbsp;to&nbsp;work&nbsp;only&nbsp;for&nbsp;&nbsp;where&nbsp;the&nbsp;local&nbsp;projection&nbsp;is&nbsp;intended&nbsp;to&nbsp;be&nbsp;used.

Another&nbsp;approach&nbsp;would&nbsp;be&nbsp;to&nbsp;used&nbsp;a&nbsp;custom&nbsp;Scale&nbsp;Bar&nbsp;based&nbsp;on&nbsp;Lat/Long&nbsp;and&nbsp;that&nbsp;would&nbsp;work&nbsp;for&nbsp;the&nbsp;entire&nbsp;world.&nbsp;What&nbsp;approach&nbsp;do&nbsp;you&nbsp;want&nbsp;us&nbsp;to&nbsp;take&nbsp;for&nbsp;you?

---

<div class="post-metadata">

**Author:** ![Gary1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@Gary1](https://community.thinkgeo.com/u/Gary1)\
**Post date:** [August 5, 2010, 4:58pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/5 "2010-08-05T16:58:23Z")

</div>

Hi&nbsp;Val,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Many&nbsp;thanks&nbsp;for&nbsp;your&nbsp;reply.&nbsp;I&nbsp;understand&nbsp;the&nbsp;issue&nbsp;with&nbsp;the&nbsp;distortion&nbsp;introduced&nbsp;with&nbsp;the&nbsp;Mercator&nbsp;projection.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’m&nbsp;not&nbsp;sure&nbsp;I&nbsp;understand&nbsp;what&nbsp;the&nbsp;implications&nbsp;are&nbsp;for&nbsp;the&nbsp;solution&nbsp;you’ve&nbsp;described&nbsp;though.&nbsp;Just&nbsp;to&nbsp;confirm&nbsp;that&nbsp;we&nbsp;use&nbsp;both&nbsp;Virtual&nbsp;Earth&nbsp;maps&nbsp;and&nbsp;shapefiles&nbsp;that&nbsp;have&nbsp;been&nbsp;reprojected&nbsp;from&nbsp;WGS84&nbsp;into&nbsp;Mercator.&nbsp;Most&nbsp;of&nbsp;the&nbsp;data&nbsp;we&nbsp;plot&nbsp;is&nbsp;stored&nbsp;in&nbsp;WGS84&nbsp;degrees,&nbsp;but&nbsp;we&nbsp;reproject&nbsp;it&nbsp;into&nbsp;Mercator&nbsp;using&nbsp;the&nbsp;managed&nbsp;projection&nbsp;library&nbsp;to&nbsp;display&nbsp;it&nbsp;on&nbsp;the&nbsp;map.&nbsp;  
&nbsp;&nbsp;  
&nbsp;We’d&nbsp;need&nbsp;something&nbsp;that&nbsp;works&nbsp;for&nbsp;the&nbsp;entire&nbsp;world,&nbsp;as&nbsp;we&nbsp;use&nbsp;maps&nbsp;for&nbsp;both&nbsp;Northern&nbsp;and&nbsp;Southern&nbsp;hemispheres.&nbsp;If&nbsp;we&nbsp;have&nbsp;a&nbsp;custom&nbsp;scale&nbsp;bar&nbsp;based&nbsp;on&nbsp;lat/lon&nbsp;will&nbsp;that&nbsp;work&nbsp;with&nbsp;our&nbsp;Mercator&nbsp;shape&nbsp;files&nbsp;and&nbsp;VE&nbsp;maps?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Best&nbsp;regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 9, 2010, 3:47pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/6 "2010-08-09T15:47:12Z")

</div>

Ok,&nbsp;tomorrow&nbsp;I&nbsp;will&nbsp;present&nbsp;to&nbsp;you&nbsp;the&nbsp;solution&nbsp;of&nbsp;a&nbsp;custom&nbsp;Scale&nbsp;Bar&nbsp;based&nbsp;on&nbsp;Lat/Long&nbsp;that&nbsp;will&nbsp;work&nbsp;Spherical&nbsp;Mercator&nbsp;map&nbsp;(VE,&nbsp;Google&nbsp;maps&nbsp;etc).&nbsp;And&nbsp;you&nbsp;will&nbsp;also&nbsp;see&nbsp;how&nbsp;to&nbsp;extend&nbsp;the&nbsp;ScaleBarAdornmentLayer&nbsp;for&nbsp;building&nbsp;such&nbsp;a&nbsp;custom&nbsp;scale&nbsp;bar.&nbsp;&nbsp;It&nbsp;will&nbsp;be&nbsp;in&nbsp;the&nbsp;Code&nbsp;Community&nbsp;for&nbsp;everybody&nbsp;to&nbsp;take&nbsp;advantage&nbsp;of.&nbsp;Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;idea.

---

<div class="post-metadata">

**Author:** ![Gary1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@Gary1](https://community.thinkgeo.com/u/Gary1)\
**Post date:** [August 10, 2010, 6:05am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/7 "2010-08-10T06:05:35Z")

</div>

Hi&nbsp;Val,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Many&nbsp;thanks&nbsp;-&nbsp;this&nbsp;is&nbsp;much&nbsp;appreciated.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Best&nbsp;regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary&nbsp;

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 10, 2010, 11:03am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/8 "2010-08-10T11:03:23Z")

</div>

Please&nbsp;check&nbsp;out&nbsp;the&nbsp;Code&nbsp;Community&nbsp;project&nbsp;_Custom&nbsp;Scale&nbsp;Bar&nbsp;_[code.thinkgeo.com/projects/show/customscalebar](http://code.thinkgeo.com/projects/show/customscalebar).&nbsp;It&nbsp;shows&nbsp;how&nbsp;to&nbsp;construct&nbsp;a&nbsp;Scale&nbsp;Bar&nbsp;based&nbsp;on&nbsp;Geodetic&nbsp;(WGS84)&nbsp;for&nbsp;a&nbsp;VE&nbsp;map.&nbsp;Note&nbsp;that&nbsp;this&nbsp;Scale&nbsp;Bar&nbsp;can&nbsp;be&nbsp;adapted&nbsp;to&nbsp;any&nbsp;other&nbsp;scenarios&nbsp;as&nbsp;you&nbsp;can&nbsp;read&nbsp;in&nbsp;the&nbsp;comments&nbsp;of&nbsp;this&nbsp;project.

 ![](https://community.thinkgeo.com/uploads/default/original/2X/1/1aa014f9298216954db986084c918d186b545af1.jpg)

---

<div class="post-metadata">

**Author:** ![Gary1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@Gary1](https://community.thinkgeo.com/u/Gary1)\
**Post date:** [August 13, 2010, 3:42am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/9 "2010-08-13T03:42:44Z")

</div>

Hi&nbsp;Val,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thank&nbsp;you&nbsp;very&nbsp;much&nbsp;for&nbsp;producing&nbsp;this.&nbsp;Is&nbsp;there&nbsp;any&nbsp;way&nbsp;to&nbsp;have&nbsp;the&nbsp;adornment&nbsp;layer&nbsp;locked&nbsp;so&nbsp;that&nbsp;it&nbsp;doesn’t&nbsp;move&nbsp;when&nbsp;the&nbsp;user&nbsp;pans&nbsp;around&nbsp;the&nbsp;map?&nbsp;I’ve&nbsp;noticed&nbsp;that&nbsp;it&nbsp;moves&nbsp;with&nbsp;the&nbsp;map&nbsp;and&nbsp;then&nbsp;snaps&nbsp;back&nbsp;into&nbsp;place.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Best&nbsp;regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 13, 2010, 9:27am UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/10 "2010-08-13T09:27:30Z")

</div>

That’s&nbsp;a&nbsp;Web&nbsp;specific&nbsp;question.&nbsp;I&nbsp;will&nbsp;ask&nbsp;the&nbsp;Web&nbsp;Team&nbsp;if&nbsp;this&nbsp;is&nbsp;possible.&nbsp;You&nbsp;should&nbsp;have&nbsp;a&nbsp;response&nbsp;on&nbsp;Monday.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [August 15, 2010, 9:21pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/11 "2010-08-15T21:21:01Z")

</div>

&nbsp;

Gary,  
Maybe&nbsp;the&nbsp;script&nbsp;below&nbsp;can&nbsp;help&nbsp;you.&nbsp;It's&nbsp;based&nbsp;on&nbsp;the&nbsp;sample&nbsp;that&nbsp;Val&nbsp;has&nbsp;provided,&nbsp;Please&nbsp;set&nbsp;it&nbsp;to&nbsp;the&nbsp;header&nbsp;part:  
  
` <script language="javascript" type="text/javascript">        var OnMapCreating = function(map) {            OpenLayers.Map.prototype.moveTo = function(lonlat, zoom, options) {                if (!options) {                    options = {};                }                if (zoom != null) {                    zoom = parseFloat(zoom);                    if (!this.fractionalZoom) {                        zoom = Math.round(zoom);                    }                }                // dragging is false by default                var dragging = options.dragging;                // forceZoomChange is false by default                var forceZoomChange = options.forceZoomChange;                // noEvent is false by default                var noEvent = options.noEvent;                if (this.panTween && options.caller == "setCenter") {                    this.panTween.stop();                }                if (!this.center && !this.isValidLonLat(lonlat)) {                    lonlat = this.maxExtent.getCenterLonLat();                }                if (this.restrictedExtent != null) {                    // In 3.0, decide if we want to change interpretation of maxExtent.                    if (lonlat == null) {                        lonlat = this.getCenter();                    }                    if (zoom == null) {                        zoom = this.getZoom();                    }                    var resolution = this.getResolutionForZoom(zoom);                    var extent = this.calculateBounds(lonlat, resolution);                    if (!this.restrictedExtent.containsBounds(extent)) {                        var maxCenter = this.restrictedExtent.getCenterLonLat();                        if (extent.getWidth() > this.restrictedExtent.getWidth()) {                            lonlat = new OpenLayers.LonLat(maxCenter.lon, lonlat.lat);                        } else if (extent.left < this.restrictedExtent.left) {                            lonlat = lonlat.add(this.restrictedExtent.left -                                                    extent.left, 0);                        } else if (extent.right > this.restrictedExtent.right) {                            lonlat = lonlat.add(this.restrictedExtent.right -                                                    extent.right, 0);                        }                        if (extent.getHeight() > this.restrictedExtent.getHeight()) {                            lonlat = new OpenLayers.LonLat(lonlat.lon, maxCenter.lat);                        } else if (extent.bottom < this.restrictedExtent.bottom) {                            lonlat = lonlat.add(0, this.restrictedExtent.bottom -                                                    extent.bottom);                        }                        else if (extent.top > this.restrictedExtent.top) {                            lonlat = lonlat.add(0, this.restrictedExtent.top -                                                    extent.top);                        }                    }                }                var zoomChanged = forceZoomChange || (                                        (this.isValidZoomLevel(zoom)) &&                                        (zoom != this.getZoom()));                var centerChanged = (this.isValidLonLat(lonlat)) &&                                        (!lonlat.equals(this.center));                // if neither center nor zoom will change, no need to do anything                if (zoomChanged || centerChanged || !dragging) {                    if (!this.dragging && !noEvent) {                        this.events.triggerEvent("movestart");                    }                    if (centerChanged) {                        //                        if ((!zoomChanged) && (this.center)) {                        // if zoom hasnt changed, just slide layerContainer                        //  (must be done before setting this.center to new value)                        //                            this.centerLayerContainer(lonlat);                        //                        }                        this.center = lonlat.clone();                    }                    // (re)set the layerContainerDiv's location                    if ((zoomChanged) || (this.layerContainerOrigin == null)) {                        this.layerContainerOrigin = this.center.clone();                        this.layerContainerDiv.style.left = "0px";                        this.layerContainerDiv.style.top = "0px";                    }                    if (zoomChanged) {                        this.zoom = zoom;                        this.resolution = this.getResolutionForZoom(zoom);                        // zoom level has changed, increment viewRequestID.                        this.viewRequestID++;                    }                    var bounds = this.getExtent();                    //send the move call to the baselayer and all the overlays                        if (this.baseLayer.visibility) {                        this.baseLayer.moveTo(bounds, zoomChanged, dragging);                        if (dragging) {                            this.baseLayer.events.triggerEvent("move");                        } else {                            this.baseLayer.events.triggerEvent("moveend",                                    { "zoomChanged": zoomChanged }                                );                        }                    }                    bounds = this.baseLayer.getExtent();                    for (var i = 0, len = this.layers.length; i < len; i++) {                        var layer = this.layers[i];                        if (layer !== this.baseLayer && !layer.isBaseLayer) {                            var inRange = layer.calculateInRange();                            if (layer.inRange != inRange) {                                // the inRange property has changed. If the layer is                                // no longer in range, we turn it off right away. If                                // the layer is no longer out of range, the moveTo                                // call below will turn on the layer.                                layer.inRange = inRange;                                if (!inRange) {                                    layer.display(false);                                }                                this.events.triggerEvent("changelayer", {                                    layer: layer, property: "visibility"                                });                            }                            if (inRange && layer.visibility) {                                layer.moveTo(bounds, zoomChanged, dragging);                                if (dragging) {                                    layer.events.triggerEvent("move");                                } else {                                    layer.events.triggerEvent("moveend",                                            { "zoomChanged": zoomChanged }                                        );                                }                            }                        }                    }                    if (zoomChanged) {                        //redraw popups                        for (var i = 0, len = this.popups.length; i < len; i++) {                            this.popups[i].updatePosition();                        }                    }                    this.events.triggerEvent("move");                    if (zoomChanged) { this.events.triggerEvent("zoomend"); }                }                // even if nothing was done, we want to notify of this                if (!dragging && !noEvent) {                    this.events.triggerEvent("moveend");                }                // Store the map dragging state for later use                this.dragging = !!dragging;            }        }    </script>`  
  
&nbsp;  
Thanks,  
Johnny

---

<div class="post-metadata">

**Author:** ![East](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/e95f7d/32.png) [@East](https://community.thinkgeo.com/u/East)\
**Post date:** [June 29, 2015, 7:55pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/12 "2015-06-29T19:55:45Z")

</div>

`Posted By Johnny on 08-15-2010 09:21 PM`

` `

`
Gary,Maybe the script below can help you. It’s based on the sample that Val has provided, Please set it to the header part: Thanks,Johnny`  
  
Thanks&nbsp;for&nbsp;the&nbsp;script.&nbsp;It’s&nbsp;of&nbsp;great&nbsp;help!  
  
  
  
Beast&nbsp;regards.  
  
[Bar&nbsp;code](http://www.keepdynamic.com/barcoding/vb-net-barcode-generator.shtml)&nbsp;[create&nbsp;barcode](http://www.keepdynamic.com/dotnet-barcode/).

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [July 1, 2015, 8:17pm UTC](https://community.thinkgeo.com/t/incorrect-distances-scales/5427/13 "2015-07-01T20:17:41Z")

</div>

Hi,&nbsp;East,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;questions,&nbsp;please&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Troy
