Select to view content in your preferred language

Detect all markers inside a given radius

1441
2
05-02-2014 01:44 AM
mxmx
by
Emerging Contributor
I have a set of coordinates that is loaded from database. I would like to detect all the loaded markers that are close to each others
which is within a certain distance.

so the code is something like

function locatePOI() { // Places of Interest
    var Grid_Table = document.getElementById('PrimarySchoolDGV');
   
 
 var xmlhttp=new XMLHttpRequest();
 xmlhttp.open("GET", "/Foreigners@SG/WebService.asmx/getPlacesOfInterests", false);
 xmlhttp.send();
    var xmlDoc = xmlhttp.responseXML;
    var xmlalbums = xmlDoc.documentElement.getElementsByTagName("PlacesOfInterest");

    $.each(xmlalbums, function () {
        testindex = 0;
        var school = $(this).find("Name").text();
        var address = $(this).find("Address").text();
        var postalcode = $(this).find("PostalCode").text();
        var cat = $(this).find("Category").text();
        var incidentI = "";

        coordX = $(this).find("X").text();
        coordY = $(this).find("Y").text();

        var point = new esri.geometry.Point({ "x": coordX, "y": coordY, "spatialReference": { "wkid": 3414} });

       if(pointsbetweeneachother < 3km)
{
// do something here
}

        var symbol = new esri.symbol.PictureMarkerSymbol('images/icons/Interest-icon1.png', 25, 25);


        //symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, safetyLevelRadiusSize * 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([r, g, b, 0.5]), 10), new dojo.Color([r, g, b, 0.9]));
        var infoTemplate = new esri.InfoTemplate();

        infoTemplate.setTitle("<img src='images/icons/interest-icon.png' style='width:25px; height:25px;'/>   " + school);
        infoTemplate.setContent("<b>Food Establishments : </b>" + school + "</br>"
                    + "<b>Address: </b>" + address + "<br/>"
                    + "<b>PostalCode: </b>" + postalcode + "<br/>"
                   + "<b>Category: </b>" + cat + "<br/>"

                   );

        var graphic = new esri.Graphic(point, symbol);
        map.graphics.add(graphic);
        graphic.setSymbol(symbol);
        graphic.setInfoTemplate(infoTemplate);

    }
 );
}


can anyone help me with this?
0 Kudos
2 Replies
NoppadonHimananto
Deactivated User
I have a set of coordinates that is loaded from database. I would like to detect all the loaded markers that are close to each others
which is within a certain distance.

so the code is something like

function locatePOI() { // Places of Interest
    var Grid_Table = document.getElementById('PrimarySchoolDGV');
   
 
 var xmlhttp=new XMLHttpRequest();
 xmlhttp.open("GET", "/Foreigners@SG/WebService.asmx/getPlacesOfInterests", false);
 xmlhttp.send();
    var xmlDoc = xmlhttp.responseXML;
    var xmlalbums = xmlDoc.documentElement.getElementsByTagName("PlacesOfInterest");

    $.each(xmlalbums, function () {
        testindex = 0;
        var school = $(this).find("Name").text();
        var address = $(this).find("Address").text();
        var postalcode = $(this).find("PostalCode").text();
        var cat = $(this).find("Category").text();
        var incidentI = "";

        coordX = $(this).find("X").text();
        coordY = $(this).find("Y").text();

        var point = new esri.geometry.Point({ "x": coordX, "y": coordY, "spatialReference": { "wkid": 3414} });

       if(pointsbetweeneachother < 3km)
{
// do something here
}

        var symbol = new esri.symbol.PictureMarkerSymbol('images/icons/Interest-icon1.png', 25, 25);


        //symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, safetyLevelRadiusSize * 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([r, g, b, 0.5]), 10), new dojo.Color([r, g, b, 0.9]));
        var infoTemplate = new esri.InfoTemplate();

        infoTemplate.setTitle("<img src='images/icons/interest-icon.png' style='width:25px; height:25px;'/>   " + school);
        infoTemplate.setContent("<b>Food Establishments : </b>" + school + "</br>"
                    + "<b>Address: </b>" + address + "<br/>"
                    + "<b>PostalCode: </b>" + postalcode + "<br/>"
                   + "<b>Category: </b>" + cat + "<br/>"

                   );

        var graphic = new esri.Graphic(point, symbol);
        map.graphics.add(graphic);
        graphic.setSymbol(symbol);
        graphic.setInfoTemplate(infoTemplate);

    }
 );
}


can anyone help me with this?


I don't sure what u need.
But this example may be involve with what u want.
[ATTACH=CONFIG]33551[/ATTACH]
1. This example is I use geometry service to buffer a point with radius that I want and it return Geometry[] set.
https://developers.arcgis.com/javascript/jsapi/geometryservice-amd.html
https://developers.arcgis.com/javascript/jsapi/bufferparameters-amd.html
2. then i pass that Geometry set to geometry reference on QueryTask and execute to find what is in that geometry
3. then I highlight all object that is in radius.

On the Example's results isn't highlight all object in radius because QueryTask return only max 1000 results.
0 Kudos
mxmx
by
Emerging Contributor
Thank you for your reply. Unfortunately it is not what i wanted. I do not need a server to return me the coords.
I have already loaded it from database. However i want to detect if all the markers are close to each other by a certain distance..
0 Kudos