I need to explicitly set my lods to control the max and min for my map. I'd like to have these stored in a separate file like lods.js and then just reference it. I'm not sure of the syntax for the file and I'm not sure how to reference it.
I have lods set up in a configuration file (projectA.js) like this
define([], function () { return { //other parameters lods: [ { "level": 0, "scale": 144447.638572, "resolution": 38.2185141425366 }, { "level": 1, "scale": 72223.819286, "resolution": 19.1092570712683 }, { "level": 2, "scale": 36111.909643, "resolution": 9.55462853563415 }, { "level": 3, "scale": 18055.954822, "resolution": 4.77731426794937 }, { "level": 4, "scale": 9027.977411, "resolution": 2.38865713397468 }, { "level": 5, "scale": 4513.988705, "resolution": 1.19432856685505 }, { "level": 6, "scale": 2256.994353, "resolution": 0.597164283559817 }, { "level": 7, "scale": 1128.497176, "resolution": 0.298582141647617 } ], //more parameters }; });
This is stored in "modules/projects", so I use the require statement
require(["modules/projects/projectA", function (parameters) {
to use them like this
map = new Map("divMap", { basemap: parameters.basemap, lods: parameters.lods, logo: false, showAttribution: false });
I think both are helpful. I'm not sure whether one methodology is more efficient or faster than the other. It seem like you a few extra lines if you put it in as a module. On the other hand, it ends up getting called the same as the other modules in my js folder, so I'm less likely to lose track of how I'm calling it.
I haven't worked with LODs myself but they're essentially a pure JS multi-dimensional array so you could just place that into a standalone JS file and load it into your project like any other JS traditional JS file. Your lods.js file would be:
var lods = [ {"level" : 0, "resolution" : 0.010986328125, "scale" : 4617149.97766929}, {"level" : 1, "resolution" : 0.0054931640625, "scale" : 2308574.98883465}, {"level" : 2, "resolution" : 0.00274658203125, "scale" : 1154287.49441732}, {"level" : 3, "resolution" : 0.001373291015625, "scale" : 577143.747208662}, {"level" : 4, "resolution" : 0.0006866455078125, "scale" : 288571.873604331} ];
Now load it anytime before your JS file which constructs the map:
<script type="text/javascript" src="js/lods.js"></script> <script src="http://js.arcgis.com/3.14/"></script>
So long as the variable has a global scope, you could then refer to it during your map construction:
var map = new Map("map", { lods: lods });
EDIT: Ken beat me to the punch. His idea is probably better.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.