I am trying to pass the geometry of a polyline from a map service layer to the elevation profile widget. Normally, when using a polyline generated from the Draw tool, we can grab the event geometry upon drawing end:

this._toolbar.on("draw-end", (e: any) => this.refreshElevationProfile(e));

refreshElevationProfile(evt): void {
    this._elevationProfileWidget.set("profileGeometry", evt.geometry);

Using an identify task, I can get the layers in my map service layer upon map click. But does anyone know how to get specifically the geometry from a feature from one of the layers? (Say the top-most layer for example)

  • Were you able to get this working? I'm facing the same requirement with the elevation profile widget.
    – Beanwah
    Jun 13, 2018 at 20:33

1 Answer 1


Something like this should do the trick.

    public selectPolyline(){
        this._mapClickHandler = this.map
            .on("click", e => this.executeIdentifyTasks(e, this.map.getLayersVisibleAtScale()));

    public executeIdentifyTasks(event: any, layers: Array<Layer>): void {

        let identifyTasks: Array<Promise<any>> = new Array<Promise<any>>();
        layers.forEach(l => {
            var ids = (<any>l).layerInfos.map(x => x.id);
            let identifyParams = this.getIdentifyParamsForRequest(event.mapPoint, this.map, [ids]);
            let identifyTask = new IdentifyTask(l.url);

        let identifiedItems: Array<any> = new Array<any>();
        Observable.forkJoin(identifyTasks).subscribe((responses: Array<IdentifyResult>) => {
            if (responses[0][0].feature.geometry.type === "polyline") {
                console.log("We have a polyline");
            responses.forEach(layerResponse => {
                if (layerResponse[0].geometryType === "esriGeometryPolyline") {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.