Cannot read property 'setTransform' of undefined

2940
6
07-07-2017 12:49 AM
重溪陳
New Contributor II

I try to develop  arcgis api application with angular-esri-components solution. I get 「Cannot read property 'setTransform' of undefined」 error message when I try to add a point graphic to the map. My Code as below:

import { Component, OnInit } from '@angular/core';
import { EsriLoaderService } from 'angular-esri-loader';
@Component({
selector: 'app-demo',
templateUrl: './demo.component.html',
styleUrls: ['./demo.component.css']
})
export class DemoComponent implements OnInit {
map: __esri.Map;
mapView: __esri.MapView;

constructor(private esriLoader: EsriLoaderService) { }

ngOnInit() {
return this.esriLoader.load({
}).then(res => {
this.esriLoader.loadModules([
'esri/Map',
'esri/views/MapView',
'esri/layers/FeatureLayer',
'esri/renderers/SimpleRenderer',
'esri/symbols/SimpleMarkerSymbol',
'esri/Color',
'esri/tasks/QueryTask',
'esri/tasks/support/Query',
'esri/geometry/SpatialReference',
'esri/layers/GraphicsLayer',
'esri/Graphic',
'esri/geometry/Point',
'esri/layers/Layer',
'dojo/domReady!'
]).then(([Map, MapView, FeatureLayer, SimpleMarkerSymbol, SimpleRenderer, Color,
QueryTask, Query, SpatialReference, GraphicsLayer, Graphic,
Point, Layer]:
[__esri.MapConstructor, __esri.MapViewConstructor,
__esri.FeatureLayerConstructor, __esri.SimpleMarkerSymbolConstructor,
__esri.SimpleRendererConstructor, __esri.ColorConstructor,
__esri.QueryTaskConstructor, __esri.QueryConstructor,
__esri.SpatialReferenceConstructor, __esri.GraphicsLayerConstructor,
__esri.GraphicConstructor, __esri.PointConstructor, __esri.Layer]) => {

this.map = new Map({
basemap: "hybrid"
});
this.mapView = new MapView({
zoom: 13,
center: [121.5, 25],
container: 'map',
map: this.map
})

let sym = new SimpleMarkerSymbol({
size: 10,
color: new Color("#0000FF"),
style: 'square',
outline: {
color: new Color("#FFFF00"),
width: 3
}
});

var markerSymbol = new SimpleMarkerSymbol({
color: new Color([226, 119, 40]),
outline: { // autocasts as new SimpleLineSymbol()
color: new Color([255, 255, 255]),
width: 2
}
});

this.mapView.on('click', evt => {
let pt = this.mapView.toScreen(evt.mapPoint);

let gc = new Graphic({
geometry: evt.mapPoint,
symbol: markerSymbol
});
this.mapView.graphics.add(gc);
console.log(evt.mapPoint);

});

});
});

}


}
0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor

The order of the modules loaded (..., 'esri/renderers/SimpleRenderer', 'esri/symbols/SimpleMarkerSymbol',...) are not the same as in the arguments (...,SimpleMarkerSymbol, SimpleRenderer,...)

0 Kudos
KenBuja
MVP Esteemed Contributor

It looks like there's a bug with SimpleFillSymbol in 4.4. Maybe SimpleMarkerSymbol has this same error

https://community.esri.com/thread/197857-simplefillsymbol 

ThomasSolow
Occasional Contributor III

Yep, looks like something going wrong in 4.4 (possibly with view.graphics).  I would recommend using 4.3 for the time being.

0 Kudos
重溪陳
New Contributor II

I had tried to use 4.3 but still get the same error message.

0 Kudos
ThomasSolow
Occasional Contributor III

JS Bin - Collaborative JavaScript Debugging

I copied your sample to a sandbox.  Seems to work fine, unsure what the issue is here.

0 Kudos
重溪陳
New Contributor II

I reconstructed the modules loader as below and working fine. It is also working for 4.4 .

0 Kudos