Select to view content in your preferred language

Scalebar - wrong start unit

727
1
03-18-2011 03:36 AM
DirkSchaefer
Deactivated User
Hello,

I´ve got a problem with the scalebar in my map: The Scalebar doesn´t show the right scale when the homepage is opened the first time. After dragging the map or after zooming, the scalebar works right. We use parts of the code from the ESRI-sample (http://help.arcgis.com/EN/webapi/javascript/arcgis/demos/widget/widget_scalebar.html).

And here is a short part out of my code:

<script type="text/javascript">djConfig = { parseOnLoad:true }</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>

<script type="text/javascript">
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("esri.map");
dojo.require("esri.toolbars.navigation");
dojo.require("esri.dijit.Scalebar");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("dijit.form.Button");
dojo.require("dijit.Toolbar");


var map, navToolbar;
function init() {


var layersLoaded = 0; //varible to keep track of when all layers have been loaded.
var loading = dojo.byId("loadingImg"); //loading image. id

esriConfig.defaults.map.sliderLabel = null;
Eintragung des Start-Extents
var startExtent = new esri.geometry.Extent
({"xmin":3447000.000000,"ymin":5758000.000000,"xmax":3464000.000000,"ymax":5772000.000000,"spatialReference":{"wkid":31467}});

map = new esri.Map("map", {extent:startExtent});
navToolbar = new esri.toolbars.Navigation(map);
dojo.connect(map, "onLoad", showLoading);
dojo.connect(map, "onZoomStart", showLoading);
dojo.connect(map, "onPanStart", showLoading);

var nr1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://nts1p008/ArcGIS/rest/services/Dienste/LP_Halle_Steinhagen/MapServer");
map.addLayer(nr1);
dojo.connect(nr1, "onUpdate", hideLoading);

var nr2 = new esri.layers.ArcGISDynamicMapServiceLayer("http://nts1p008/ArcGIS/rest/services/Dienste/TK50_SW_red/MapServer");
map.addLayer(nr2);
dojo.connect(nr2, "onUpdate", hideLoading);

dojo.connect(dijit.byId('map'), 'resize', function() { //resize the map if the div is resized
clearTimeout(resizeTimer);
var resizeTimer = setTimeout(function() {
map.resize();
map.reposition();
}, 500);
});
dojo.connect(map, 'onLoad', function(map) {
var scalebar = new esri.dijit.Scalebar({
map: map,
scalebarUnit:'metric'
});

});


function showLoading() {
esri.show(loading);
map.hideZoomSlider();
}

function hideLoading() {
layersLoaded++;
if (layersLoaded === map.layerIds.length) {
esri.hide(loading);
map.showZoomSlider();
layersLoaded = 0;
}
}
}

function extentHistoryChangeHandler() {
dijit.byId("zoomprev").disabled = navToolbar.isFirstExtent();
dijit.byId("zoomnext").disabled = navToolbar.isLastExtent();


}
dojo.addOnLoad(init);
esri.config.defaults.map.logoLink = "http://www.kreis-guetersloh.de";

</script>
</head>



Maybe someone have recognized the same problem with the scalebar. Please let me know If you need more code. It would be nice if you can help me.

Thanks.
0 Kudos
1 Reply
hcgis
by
Deactivated User
hi Dirk
did you solve this issue, for me the scalebar indicates big numbers all time and the browser freezes when loading the application. when i remove the scalebar the problem disappear and everything works correctly. Have you any idea about using scalebar for spatialrefence different than web mercator and WGS 84
Regards
0 Kudos