Good day all,
I am new to web app builder widget... I require to create a widget that pass location bbox to a server. How can I complete this on widget load. Any sample code or JS API link will be great.
Thanks in advance for your assistance.
Solved! Go to Solution.
Raju,
So if your web service is a RESTful web service you would use esriRequest to send the data.
var requestHandler = esriRequest(yourServiceURL,{
content: {
yourParmeter: extentString
},
responseType: "json"
});
Raju,
Passing a map extent back to the server would require a web service or something that can accept the extent. So what do you have on the server that is expecting the extent?
Thanks Rob for your response. I already have a web service setup that expect current application map extent. I am looking a function in JS 4.x that send current application location(lat, long) or bbox. how to get zoom level. Please see example below and advise. Thanks in advance
Set and use extents in a map | Guide | ArcGIS API for JavaScript 3.24
function init(){
var myMap = new Map("mapDiv");
var mapServiceURL = "https://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
myMap.addLayer(new ArcGISTiledMapServiceLayer(mapServiceURL));
myMap.addLayer(mapServiceURL);
myMap.on("extent-change", showExtent);
}
function showExtent(ext){
var extentString = "";
extentString = "XMin: " + ext.xmin +
" YMin: " + ext.ymin +
" XMax: " + ext.xmax +
" YMax: " + ext.ymax;
document.getElementById("onExtentChangeInfo").innerHTML = extentString;
Raju,
So if your web service is a RESTful web service you would use esriRequest to send the data.
var requestHandler = esriRequest(yourServiceURL,{
content: {
yourParmeter: extentString
},
responseType: "json"
});