Select to view content in your preferred language

Retrieve the list of points visible on the map

1326
2
08-26-2016 05:07 AM
HaithemLabbassi
Deactivated User

Hello,

I have a map with points of full above, or zoom in or out I want to receive on javascript the list of items that is visible on the map , like airbnb website

 

Here is a sample list refresh suite the zoom in/out and move the map:

Top 20 des locations de vacances à Amsterdam, locations saisonnières et location d'appartements - Ai... 

 

Thanks

#js api 4.0

Tags (1)
0 Kudos
2 Replies
BillChappell
Frequent Contributor

Have you looked at http://esri.github.io/esri-leaflet/api-reference/tasks/query.html ?

My example was in Leaflet, In ArcGIS JS, you could basically do the same thing.

Get the map extent on change and then query the feature layers. This code may help.

require([
  "esri/tasks/query", "esri/layers/FeatureLayer", ...
], function(Query, FeatureLayer, ... ) {
  var query = new Query();
  var featureLayer = new FeatureLayer( ... );
  query.geometry = feature.geometry;     /////////////////////////////////////////Plug in current map extent
  featureLayer.selectFeatures(query,FeatureLayer.SELECTION_NEW);
  ...
});
////////////////////////////////////////////////

require(["esri/map"], function(Map) {
  var map = new Map( ... );
  map.on("extent-change", function(){
    var geo = map.geographicExtent;     /////////////Plug this into the query?
    console.log(geo.xmin, geo.ymin, geo.xmax, geo.ymax);
  });
  ...
});

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

in order to create something similar with the example provided you have to create and run a query task every time you change extent or move map.

This query Task will have as spatial geometry condition the map extent and as attributes the user parameters (money, area e.t.c).

spatially you can minimize the query using the parameter query.geometry and setting equal to the current map extent.

Query | API Reference | ArcGIS API for JavaScript 4.0 

0 Kudos