Folks
Please look at the example below. I am adding a map but would like to pass in the extent from an outside source...either a URL parameter or a QueryTask from a table. It seems that the order of operation for JavaScript is stumping me. The map requires the extent info prior to querying the extent. Please show me how to proceed. Thank you.
Keith
I think the problem is, the result is a string, not a array
that should work:
map = new Map("map", { basemap: "topo", center: JSON.parse(cityextent), // longitude, latitude zoom: 13 });
if you want to be sure use a callback:
require(["esri/map", "dojo/Deferred", "dojo/domReady!"], function (Map, Deferred) { GetUrlValue('extent').then(function (centerPoint) { console.info(centerPoint); map = new Map("map", { basemap: "topo", center: JSON.parse(centerPoint), zoom: 13 }); }); function GetUrlValue(VarSearch) { var deferred = new Deferred(); var SearchString = window.location.search.substring(1); var VariableArray = SearchString.split('&'); for (var i = 0; i < VariableArray.length; i++) { var KeyValuePair = VariableArray.split('='); if (KeyValuePair[0] == VarSearch) { deferred.resolve(KeyValuePair[1]); } return deferred.promise; } } });
Rene
I did get an answer to this.
Thank you for you reply.
Keith Anderson
LOGIS GIS
5750 Duluth St
Golden Valley MN 55422
763-543-2641(w)
763-226-7061(c)
kanderson@logis.org<mailto:kanderson@logis.org>
Sorry for the delay.
Have you found a solution? If not, can you post the result of
qTask.execute(QT, function (results) { console.log(results); // post the result ... ...}
If you get a chance....
Trying to pull out database values on startup of the application.
Added another dojo/Deffered as you did for GetURLValue().
Stuck.
Thanks
Thank you for the reply's!
Very grateful to both of you.
What I've done is to create the map with information from an external file (read into the parameters variable), then set its extent from the file after the map is loaded
map = new Map("divMap", { basemap: parameters.basemap, //extent: new Extent(parameters.extent), lods: parameters.lods, logo: false, showAttribution: false });
map.on("load", function () { initialExtent = new Extent(parameters.extent); map.setExtent(initialExtent, true);
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.