Select to view content in your preferred language

See the result of a query on the map with Arcgis Api JS

1569
7
Jump to solution
11-08-2016 09:19 AM
MarinaSánchez
Deactivated User

Let's say you enter these parameters. Which method of the "ArcGISImageServiceLayer" class can serve to display the image of the mosaic dataset? In the attached image the result is an image, but I do not know how to visualize it on the map.

query

Part of my code is this, I used the "queryVisibleRasters" method to try to visualize it, but it did not work, any suggestions are very well received, thanks!

code

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Marina,

   I think you are thinking that the queryVisibleRasters method is suppose to just return the raster that intersects or sets the definition expression or something. What it actually does is return the geometry of the raster footprint that intersects the provided geometry. Here is a sample of what it actually does:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Simple Image Service</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css" />

    <style>
      html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; }
    </style>

    <script src="https://js.arcgis.com/3.18/"></script>
    <script>
      var map, gl, symbol;
      require([
        "esri/map", "esri/layers/ArcGISImageServiceLayer", "esri/tasks/query", "esri/geometry/Point", "esri/layers/GraphicsLayer",
        "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color", "esri/layers/ImageServiceParameters", "dojo/on", "dojo/domReady!"
      ], function(
        Map, ArcGISImageServiceLayer,  Query, Point, GraphicsLayer,
        SimpleFillSymbol, SimpleLineSymbol, Color, ImageServiceParameters, on
      ) {

        map = new Map("map", {
          basemap: "topo",
          center: [-79.40, 43.64],
          zoom: 12
        });

        gl = new GraphicsLayer();
        symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255,0,0]), 2),new Color([255,255,0,0.25]));
        var params = new ImageServiceParameters();
        params.noData = 0;
        var imageServiceLayer = new ArcGISImageServiceLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer", {
          imageServiceParameters: params,
          opacity: 0.75
        });
        map.addLayers([gl, imageServiceLayer]);

        on(imageServiceLayer, "update-end", function(){
          var query = new Query();
          query.returnGeometry = true;
          query.pixelSize = "{'x': 0.18, 'y': 0.18}";
          query.geometry = new Point(-79.40, 43.64);
          query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;

          imageServiceLayer.queryVisibleRasters(query, null, function(result){
            gl.add(result[0].setSymbol(symbol));
          });
          imageServiceLayer.setVisibility(true);
        });
      });
    </script>
  </head>

  <body>
    <div id="map"> </div>
  </body>

</html>

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Marina,

   Where is your code to handle the returned promise from the queryVisibleRasters?

0 Kudos
MarinaSánchez
Deactivated User

Is stored in the query object:

query.returnGeometry = true;
query.where = "Name LIKE '2011-01-07T182914%' AND Name NOT LIKE 'Ovr%'";
query.pixelSize = "{'x': 0.18, 'y': 0.18}";
query.geometryType = "esriGeometryPoint&geometry=-103.069,26.139";
query.spatialRel = "esriSpatialRelIntersects";

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marina,

   No, I am talking about the callback function that you would use to do something with the returned rasters.

The queryVisibleRasters =

Returns the rasters that are visible in the area defined by the geometry (required to be point or polygon) in the query parameter.
0 Kudos
MarinaSánchez
Deactivated User

Hi, Robert

I'm taking the queryVisibleRasters to display on the map the result of the query, Sorry if I do not understand your last comment. Need something in my code? At the push of a button I call this method

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marina,

   I think you are thinking that the queryVisibleRasters method is suppose to just return the raster that intersects or sets the definition expression or something. What it actually does is return the geometry of the raster footprint that intersects the provided geometry. Here is a sample of what it actually does:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Simple Image Service</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css" />

    <style>
      html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; }
    </style>

    <script src="https://js.arcgis.com/3.18/"></script>
    <script>
      var map, gl, symbol;
      require([
        "esri/map", "esri/layers/ArcGISImageServiceLayer", "esri/tasks/query", "esri/geometry/Point", "esri/layers/GraphicsLayer",
        "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color", "esri/layers/ImageServiceParameters", "dojo/on", "dojo/domReady!"
      ], function(
        Map, ArcGISImageServiceLayer,  Query, Point, GraphicsLayer,
        SimpleFillSymbol, SimpleLineSymbol, Color, ImageServiceParameters, on
      ) {

        map = new Map("map", {
          basemap: "topo",
          center: [-79.40, 43.64],
          zoom: 12
        });

        gl = new GraphicsLayer();
        symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255,0,0]), 2),new Color([255,255,0,0.25]));
        var params = new ImageServiceParameters();
        params.noData = 0;
        var imageServiceLayer = new ArcGISImageServiceLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer", {
          imageServiceParameters: params,
          opacity: 0.75
        });
        map.addLayers([gl, imageServiceLayer]);

        on(imageServiceLayer, "update-end", function(){
          var query = new Query();
          query.returnGeometry = true;
          query.pixelSize = "{'x': 0.18, 'y': 0.18}";
          query.geometry = new Point(-79.40, 43.64);
          query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;

          imageServiceLayer.queryVisibleRasters(query, null, function(result){
            gl.add(result[0].setSymbol(symbol));
          });
          imageServiceLayer.setVisibility(true);
        });
      });
    </script>
  </head>

  <body>
    <div id="map"> </div>
  </body>

</html>
MarinaSánchez
Deactivated User

Thank you, Robert.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.

0 Kudos