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);
}
});
}
}
Solved! Go to Solution.
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?