closest facility

100
2
12-20-2019 12:45 PM
jaykapalczynski
Frequent Contributor

I am looking at the example and having a hard time trying to figure out how to replace the hospital locations defined in the facilitiesOverlay, with features that I would have in a RestEndpoint.  Say my hospitals were in a RestEndPoint....

GraphicsOverlay {

        id: facilitiesOverlay

I think this would have to be manipulated as well?  

    function createFacilities() {
        featureLayerFishing.featureTable.forEach(function(graphic) {
        //featureLayerFishing.graphics.forEach(function(graphic) {
            var facility = ArcGISRuntimeEnvironment.createObject("Facility", {geometry: featureLayerFishing.geometry});
            facilities.push(facility);
        });
    }

I should be able to place the FeatureLayer in the map as such correct?

I tried to modify the createFacilities function above but did no justice as I am not sure how to approach this...

Any thoughts?

        Map {
            BasemapStreets {}

            initialViewpoint: ViewpointCenter {
                Point {
                    x: -13041154
                    y: 3858170
                    spatialReference: SpatialReference { wkid: 3857 }
                }
                targetScale: 1e5
            }
            FeatureLayer {
                id: featureLayerFishing

                ServiceFeatureTable {
                    id: featureTable0
                    url: "https://vvv.vvv.vvv.gov/arcgis/rest/services/Projects/vvv/FeatureServer/2"
               }
            }
            onLoadStatusChanged: {
                createFacilities();
                task.load();
            }
        }

0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

Based on the FeatureTable doc, FeatureTable QML Type | ArcGIS for Developers, I don't think you can call forEach out of the QML type. 

The key here is to query the features from the FeatureTable, then add them (the geometry) to the facilities array. 

0 Kudos
jaykapalczynski
Frequent Contributor

alright will look into that....thanks Erwin

0 Kudos