Hi all
What I'm trying to do is (using WebApp Builder) is to see how a point placed on the map is from the closet vehicle depot. I can get the geometry of the point being placed on the map easily but I can't figure out how to get the geometry of the depot. This is being down through a custom WebApp Builder widget.
What I am trying to do is using a query from the REST endpoint is create an object (that is not displayed on the map) with the geometry (location) and name for all the depots. I will then use the point placed on the map and the object from the JSON query to plug into a closest facility service.
Attached is a copy of the JSON returned when I put the query URL into the web browser.
Any help will be really appreciated
Cheers
Hamish,
So what is it that you need from this json? What are the required inputs for the closest facility service?
I'm not 100% sure but I'm guessing it will be a point object with a geometry
Hey Hamish,
Your post is a little tricky to decipher. Are you able to confirm the following:
If I can get some clarification I might be able to help you a little bit more.
Or you can message me privately and we can chat on the phone.
Thanks
Sam
Sorry! wrote it in a bit of rush.
1. Driving distance - have a service published to our server
2. I can access the geometry ect for the point on the map
3. I have access to a map service with the depot locations
I was initially using CMV and had no issues, but the client wanted it done in WebApp Builder and because it's using a WebMap from AGOL the layers are being shown as images not features with geometry. I could load the layers and not display them but I though doing it (getting the depot locations) with JSON would be quicker as it has less overhead(?).
Okay, that makes sense so far - with one exception. You said "because it's using a WebMap from AGOL the layers are being shown as images not features with geometry" - the webmap doesn't define whether its an image or a feature. Do you mean that you are using a tiled service in the webmap?
However, more to the point once you have the depot points how do you intend to get the closest facility?
Sam
However, if you want to get the point features from the facilities feature service you could probably do a query like the one below:
[servername]/arcgis/rest/services/[mapservicename]/MapServer/[layerIndex]/query?where=objectid>1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=json
This simply asks for all the features with an ObjectID > 0 and asks for all fields to be returned ('*'). You could be specific about which fields you want returned.
If you want to see the REST form for creating the query you could just change the 'f' parameter to equal 'html' so:
[servername]/arcgis/rest/services/[mapservicename]/MapServer/[layerIndex]/query?where=objectid>1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=html
Thanks for that - that query is similar to what i used to get the JSON attached to my op.
Looking at the source (using firebug in FF) i have been unable to find any geometry data associated with any layers displayed in the map. I have only been able to find div tags which display an image and change when the layers are changed. They're published to our dev server as MapServices and then have been added to My Content in AGOL and then included in the WebMap which is being used by the WebApp Builder.
Once i had the geometry of the depots and user specified locations I was going to pass these into a NA Service hosted on our dev server.
I'm pretty sure that I understand what you are thinking now. That approach sounds reasonable providing you don't have many facilities. The limitation is that every time you want to find the nearest route you will be passing the clicked location + all the facility features to the server each time as parameters. This is potentially really inefficient.
An alternative option might be to create a geoprocessing service which:
- Accepts a point as an input parameter
- Does all the routing and finds the nearest facility based on the source data server side
- returns the nearest facility as a point feature
Make sense?
Sam
There will be 4 facilities and no more than (in the worst case) 8 or 9 incidents