Select to view content in your preferred language

Closest Facility works but will not draw route graphic in javascript application

991
3
Jump to solution
07-24-2014 12:33 AM
JohnPapageorgiou
New Contributor III

Hi,

I have a javascript application that does closest facility analysis/routing.  When the point is placed, the nearest facility is detected and and the directions are returned, but the graphic route is never drawn or displayed.  Any ideas what may be causing this or possible solutions?  The code can be viewed at the following link: Closest Facilities .

Thanks,

John

0 Kudos
1 Solution

Accepted Solutions
TracySchloss
Frequent Contributor

I don't see that you have the outSpatialReference set on your ClosestFacilityParameters.   You'd want to specify it the same as your map spatialReference. 

View solution in original post

0 Kudos
3 Replies
MatthewLofgren
Occasional Contributor

(edit - cant figure out how to format code...)

The spatial reference of the returned routes is different than that of the map.

"spatialReference" : {

  "wkid" : 26912,

  "latestWkid" : 26912

  },

Also, maybe it has something to do with the M geometry? I don't really know much about that, but it is different than the example ESRI uses.

"geometry" : {

  "hasM" : true,

  "paths" : [[[385257.9112999998, 3703188.5214000009, 0], [385237.77309999987, 3703187.1098999996, 0.013684333276748657],

Your code works fine when adding a graphic with map.spatialReference and no M values in the paths.

So, I would look into configuring your feature service differently (changing spatial ref and maybe disabling the M values)

as an example, this one will show up in San Francisco near the bay bridge.

//routeGraphicLayer.add(route);

routeGraphicLayer.add(new Graphic({

    "geometry": {

        "paths": [

            [

                [

                    -13626301.5909,

                    4548855.381700002

                ],

                [

                    -13626306.0602,

                    4548859.846299998

                ],

                [

                    -13626310.513,

                    4548864.071800001

                ],

                [

                    -13626336.1165,

                    4548888.016599998

                ],

                [

                    -13626402.9082,

                    4548957.034100004

                ],

                [

                    -13626419.6061,

                    4548972.527900003

                ],

                [

                    -13626454.1152,

                    4549027.460600004

                ],

                [

                    -13626469.699900001,

                    4549158.455300003

                ],

                [

                    -13626500.8693,

                    4549282.408699997

                ],

                [

                    -13626399.568599999,

                    4549300.7201000005

                ],

                [

                    -13626217.0046,

                    4549327.483000003

                ],

                [

                    -13626205.636300001,

                    4549242.3728

                ]

            ]

        ],

        "spatialReference": {

            "wkid": 102100,

            "latestWkid": 3857

        }

    },

    "attributes": {

        "0": "Start at Location 1",

        "1": "Go northwest on 5th St toward Mint Plz",

        "2": "Turn right on O'Farrell St (Ofarrell St)",

        "3": "Turn right on Stockton St",

        "4": "Finish at Location 2"

    },

    "infoTemplate": {

        "title": "Attributes",

        "content": "${*}"

    }

}));

0 Kudos
JohnPapageorgiou
New Contributor III

Matthew,

thanks for replying with suggestions.  I just need a little further guidance.  Right now all the data is in NAD 83 UTM zone 12.  Do I need to reproject it all into wgs84 web mercator auxiliary sphere and then publish the service again?  Or is there another setting that can be changed in the existing Network Analyst Service?

thanks,

John

0 Kudos
TracySchloss
Frequent Contributor

I don't see that you have the outSpatialReference set on your ClosestFacilityParameters.   You'd want to specify it the same as your map spatialReference. 

0 Kudos