lol, Me: Well that's a big flippn question! Gotta see what the answer is ; )
function buildUrl() { //This function constructs a url argument to use when passing shared urls. var mext, dfrom, dto, ll, ur, xa, xg, xf, xt, ct; mext = dijit.byId("map").getMap().extent; dfrom = dijit.byId("dateFrom").value; dto = dijit.byId("dateTo").value; ll = "" + mext.xmin + "," + mext.ymin; ur = "" + mext.xmax + "," + mext.ymax; xa = dijit.byId("sp").searchaddress; xg = dijit.byId("gmSelectAreas").value; xf = "" + (1 + dfrom.getMonth()) + "+" + dfrom.getDate() + "+" + dfrom.getFullYear(); xt = "" + (1 + dto.getMonth()) + "+" + dto.getDate() + "+" + dto.getFullYear(); ct = dojo.cookie("ct"); //return window.location.protocol + "//" + window.location.host + window.location.pathname + "?" + dojox.encoding.crypto.Blowfish.encrypt("ll=" + ll + "&ur=" + ur + ((xa) ? "&xa=" : "") + xa + ((xg) ? "&xg=" : "") + xg + "&xf=" + xf + "&xt=" + xt + "&ct=" + ct, "slcpd"); return window.location.protocol + "//" + window.location.host + window.location.pathname + "?ll=" + ll + "&ur=" + ur + ((xa) ? "&xa=" : "") + xa + ((xg) ? "&xg=" : "") + xg + "&xf=" + xf + "&xt=" + xt + "&ct=" + ct; } function getValuesFromURL(name,urlstring) { //Utility function for finding a url argument in a url. See how it is used below. //Use RegExp to clean up the URL and to search for the given parameter name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(urlstring); if (results === null) { return ""; } else { return (results[1]); } } //In body of main code for page var sstring = window.location.search; urlargs = { ll: dojo.map(getValuesFromURL("ll", sstring).split("%2c"),function(x) { return parseFloat(x);},this), //Lower left ur: dojo.map(getValuesFromURL("ur", sstring).split("%2c"),function(x) { return parseFloat(x);},this), //Upper right xa: getValuesFromURL("xa", sstring).split("+").join(" "), //Search Address xg: getValuesFromURL("xg", sstring), //geokey to a specific location xf: new Date(Date.parse(getValuesFromURL("xf", sstring).split("+").join(" "))), //Date from xt: new Date(Date.parse(getValuesFromURL("xt", sstring).split("+").join(" "))), //Date to xs: getValuesFromURL("xs", sstring), //Sort by xk: getValuesFromURL("xk", sstring), //Skin ct: getValuesFromURL("ct", sstring) //Crime Types }; urlargs.xf = (urlargs.xf > 0) ? urlargs.xf : ""; urlargs.xt = (urlargs.xt > 0) ? urlargs.xt : ""; //This part is wrapped in a large try...catch because bad arguments can throw errors if (urlargs.xs) { dojo.cookie("xs", urlargs.xs); } //Then still yet farther down, when I am creating the map object options = { extent: urlargs.urlextent || urlargs.initextent //There is more, but that is the key part for extent }; //And then I pass that options object as the 2nd argument when creating the map if (urlargs.ll[0] && urlargs.ll[1] && urlargs.ur[0] && urlargs.ur[1]) { urlargs.urlextent = new esri.geometry.Extent({ "xmin": urlargs.ll[0], "ymin": urlargs.ll[1], "xmax": urlargs.ur[0], "ymax": urlargs.ur[1], "spatialReference": { "wkid": 102113 } }); } else { urlargs.initextent = new esri.geometry.Extent({ "xmin": -10137766.624432003, "ymin": 4628644.247807602, "xmax": -9998498.358896358, "ymax": 4711960.608638476, "spatialReference": { "wkid": 102113 } }); }
function getUrlParam(name, url) { // optionally pass an URL to parse if (!url) url = window.location.href; // if no parameter url is given, use the page URL name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); // instruction needed if we want to extract an array var results = new RegExp("[\\?&]"+name+"=([^&#]*)").exec(url); if( results == null ) return null; // if the name is not found, return null else // decodeURIComponent doesn't recognize '+' as encoding for space return decodeURIComponent(results[1].replace(/\+/g," ")); }
Hi there Can I see how you have been used this code?