How can i convert coordinates to routeparam compatible stops in order to carry out a RouteTask?
These coordinates are coming from the browser geolocation. Currently when i click on a point and then use the geolocation from the browser I get an error from attempting to solve the route, however when i click on 2 separate points the route solves successfully.
Solved! Go to Solution.
Yes you can but it believe it will expect that all stops be in the same WKID. So just use webmercatorutils geographictowebmercator
Evon,
I would add a spatial reference.
let stop = new Graphic({
geometry: new Point(position.coords.longitude,position.coords.latitude, new SpatialReference({ wkid: 4326 })),
symbol: stopSymbol
});
routeParams.stops.features.push(stop);
Let me go try that now, but if it is something so simple I am going to beat myself lol. I don't know why i wouldn't think of that.
Actually adding a spatial reference to the point object, results in the point not being symbolized on the map at all
Try this then:
let pnt = new Point(position.coords.longitude,position.coords.latitude, new SpatialReference({ wkid: 4326 }));
let stop = new Graphic(pnt, stopSymbol);
routeParams.stops.features.push(stop);
Still not working, if i click and add two points it will work but it seems the calculated geo position from the browser longitude and latitude just doesn't convert at all.
The point shows up on the map, it just won't carry out the routing
Evon,
This is pretty strange. I wonder if it is the fact that the geoloaction graphic is WGS84 and the other graphics in the stops array are WebMercator 102100.
That could be the case, because the routing works when i manually click two points. At the same time though Robert, the symbol for the marker (the black cross) shows up at the right point on the map. This is crazy, can I just add the point to the stops.features?
Yes you can but it believe it will expect that all stops be in the same WKID. So just use webmercatorutils geographictowebmercator