pass bbox parameters

665
3
Jump to solution
06-04-2018 06:59 PM
rajujee
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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"
});

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

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?

0 Kudos
rajujee
New Contributor III

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;

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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"
});
0 Kudos