Can't create new Polyline

346
2
Jump to solution
10-25-2022 02:01 AM
Labels (1)
Zoggo
by
New Contributor III

I can't create a new Polyline Geomtery Object in Experience Builder 1.5. If I use the code

 

 

new polyline({..})

 

 

my widget will not be loaded any more (fail to load):

 

 

import Polyline from 'esri/geometry/Polyline';

zoomTo = (geom: IGeometry) => {
    if (this.jimuMapView) {
      const pl = new Polyline({
        paths: (geom as IPolyline).paths,
        spatialReference: geom.spatialReference
        
      });
      this.jimuMapView.view.goTo(pl).catch(function (error) {
        if (error.name != "AbortError") {
          console.error(error);
        }
      });
    }
  }

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Zoggo
by
New Contributor III

This is the solution

Try adding this to your manifest.json:

 "dependency": [
    "jimu-arcgis"
  ]

View solution in original post

0 Kudos
2 Replies
Zoggo
by
New Contributor III

It seems to be a Import problem. if I use 

import Polyline from 'esri/geometry/Polyline';

the widget can't load when I use new Polygon({..}).

if I use use

constructor(props) {
    super(props);
    loadArcGISJSAPIModules([
      "esri/geometry/geometryEngine",
      "esri/geometry/Polyline"
    ]).then((modules) => {
      [this.geometryEngine, this.polyline] = modules;
      console.log("ESRI API Moduls loaded");
    });
  }

I can use the Polygon type like this

zoomTo = (geom: IGeometry) => {
    if (this.jimuMapView) {
      const pl = new this.polyline({
        paths: (geom as IPolyline).paths,
        spatialReference: geom.spatialReference
        
      });
      this.jimuMapView.view.goTo(pl).catch(function (error) {
        if (error.name != "AbortError") {
          console.error(error);
        }
      });
    }
  }

But I don't understand why I can't use import?

0 Kudos
Zoggo
by
New Contributor III

This is the solution

Try adding this to your manifest.json:

 "dependency": [
    "jimu-arcgis"
  ]
0 Kudos