Hello,
I am trying to make a function where I can locate near by points. The idea is that I click on a point in the map and a hitTest would return the graphic. This graphic would be the center point and I would find all points within a given radius. Ideally I would want to know the point and the distance and in a array.
I am lost at the moment, I am working with multiple Feature Layers. If possible to point me to an example that would be perfect.
Here is a sample of what I am doing at the moment.
""""""""""""""""""""""" This point gives me the graphics objec I clicked on """"""""""""""""""""""""""""""""'
bd4sp.view.hitTest(event)
.then(bd4sp.getGraphics) //gets the graphics
.then(bd4sp.createDistanceLayer); // creates the lines for distance
""""""""""""""""""""""""""""""""""""""
***********************************************************************************************************************************
// This function takes the response and tries
getGraphics: function (response) {
//clearPolyline(); //clear old lines
var graphic = response.results[0].graphic; //the top most graphic from the click location
console.log("Graphic Object", graphic['geometry']);
var close_points = bd4sp.geo_engine.nearestVertices(graphic['geometry'],graphic['geometry'], 300, 20);
console.log("Close Points", close_points);
//Obtain lat and long form graphic information
var p_o_i = bd4sp.point_of_intrest[0].geogrpraphic_proximity; // point of intrests
var lat_long_arry = [];
var polyarry = [];
for (var make in p_o_i) {
for (var i = 0; i < p_o_i[make].length; i++) {
var x = p_o_i[make].x;
var y = p_o_i[make].y;
lat_long_arry.push({x,y});
}
}
polyarry = bd4sp.getAllClosePoints(graphic.geometry['latitude'], graphic.geometry['longitude'], lat_long_arry); //array of graphic lines
console.log("LINES TO DRAW ->", polyarry);
return polyarry;
}
***********************************************************************************************************************************
This
var close_points = bd4sp.geo_engine.nearestVertices(graphic['geometry'],graphic['geometry'], 300, 20);
returns an array but I always get 0 because its the same point, is there a way to have one argument only?