jwerts / jsapi4-angular2 Goto Github PK
View Code? Open in Web Editor NEWTesting esri jsapi4 with angular 2
Home Page: http://joshwerts.com/jsapi4-angular2
License: MIT License
Testing esri jsapi4 with angular 2
Home Page: http://joshwerts.com/jsapi4-angular2
License: MIT License
Hi,
I have followed your example and used the same pattern on my project. The current problem that I have is that it seems like I cannot change the layers on the fly, what I mean is that I have added a method on the map service to change the tile layers according to the user selection:
here is my method to add tile layers:
public addTileMapLayer(layerData) {
let tileLayer = new TileLayer({
url: layerData.url,
title: layerData.name
});
this.map.layers.removeAll();
this.map.add(tileLayer);
}
the above method does not seem to work outside the map service, however if I call the same method in the map service constructor then all is well.
I would like to be able to call the method when I consume the service on the other component and be able to change the map layers according to the user selection. Please assist
here is an example of calling the map service method from my layer component and the map does not get rendered with the new layer that I have selected :
public onClick(legendLayer) {
var map = this._mapService.map;
this._mapService.addTileMapLayer(legendLayer);
}
would you give an example to show how to start by webpack? thanks
I am using TypeScript 2.0 compiller. When I try to build your app, I am receiving the below errors. How did you manage to get around these? I am specifically interested in the esri-related ones. I am trying to upgrade a project of my own and am encountering build errors. When I try to resolve them by using require syntax and Typings then run the app I get runtime errors.
app/app.component.ts(1,35): error TS2307: Cannot find module '@angular/core'.
app/app.component.ts(4,19): error TS2307: Cannot find module 'esri/geometry/Point'.
app/app.component.ts(5,21): error TS2307: Cannot find module 'esri/Graphic'.
app/app.component.ts(6,32): error TS2307: Cannot find module 'esri/symbols/SimpleMarkerSymbol'.
app/app.component.ts(7,19): error TS2307: Cannot find module 'esri/Color'.
app/app.module.ts(1,31): error TS2307: Cannot find module '@angular/core'.
app/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
app/app.module.ts(3,32): error TS2307: Cannot find module '@angular/http'.
app/attribute.component.ts(1,35): error TS2307: Cannot find module '@angular/core'.
app/attribute.component.ts(3,24): error TS2307: Cannot find module 'esri/core/Collection'.
app/main.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
app/map.component.ts(1,61): error TS2307: Cannot find module '@angular/core'.
app/map.component.ts(4,21): error TS2307: Cannot find module 'esri/views/MapView'.
app/map.component.ts(5,19): error TS2307: Cannot find module 'esri/geometry/Point'.
app/map.component.ts(6,30): error TS2307: Cannot find module 'esri/geometry/SpatialReference'.
app/map.service.ts(1,28): error TS2307: Cannot find module '@angular/core'.
app/map.service.ts(3,17): error TS2307: Cannot find module 'esri/Map'.
app/map.service.ts(4,27): error TS2307: Cannot find module 'esri/layers/GraphicsLayer'.
app/points.model.spec.ts(3,21): error TS2307: Cannot find module 'esri/Graphic'.
app/points.model.spec.ts(4,19): error TS2307: Cannot find module 'esri/geometry/Point'.
app/points.model.spec.ts(6,1): error TS2304: Cannot find name 'describe'.
app/points.model.spec.ts(21,3): error TS2304: Cannot find name 'beforeEach'.
app/points.model.spec.ts(25,3): error TS2304: Cannot find name 'it'.
app/points.model.spec.ts(26,5): error TS2304: Cannot find name 'expect'.
app/points.model.spec.ts(27,5): error TS2304: Cannot find name 'expect'.
app/points.model.spec.ts(30,3): error TS2304: Cannot find name 'describe'.
app/points.model.spec.ts(31,5): error TS2304: Cannot find name 'it'.
app/points.model.spec.ts(34,8): error TS2304: Cannot find name 'expect'.
app/points.model.spec.ts(37,5): error TS2304: Cannot find name 'it'.
app/points.model.spec.ts(39,7): error TS2304: Cannot find name 'expect'.
app/points.model.spec.ts(42,5): error TS2304: Cannot find name 'it'.
app/points.model.spec.ts(46,7): error TS2304: Cannot find name 'expect'.
app/points.model.spec.ts(50,3): error TS2304: Cannot find name 'describe'.
app/points.model.spec.ts(51,5): error TS2304: Cannot find name 'it'.
app/points.model.spec.ts(54,7): error TS2304: Cannot find name 'expect'.
app/points.model.ts(1,28): error TS2307: Cannot find module '@angular/core'.
app/points.model.ts(3,21): error TS2307: Cannot find module 'esri/Graphic'.
app/points.model.ts(4,27): error TS2307: Cannot find module 'esri/layers/GraphicsLayer'.
app/points.model.ts(5,24): error TS2307: Cannot find module 'esri/core/Collection'.
Hi,
I am facing issue while running the unit tests
karma start
Chrome 58.0.3029 (Windows 10 0.0.0) ERROR
Uncaught ReferenceError: require is not defined
at node_modules/esri-system-js/dist/esriSystem.js:75
Thanks,
Kunal
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.