Sean Olson
seanolson-io
Get the code samples, slides and resources from this presentation:
A tiny library to help load ArcGIS API for JavaScript modules in non-Dojo applications
https://github.com/Esri/esri-loader
$ npm install -g @angular/cli
$ ng new < application-name > [options]
$ ng generate < type > [options]
$ ng serve [options]
$ ng build [options]
for more complete list of CLI commands checkout the Angular CLI Wiki
# from your terminal, run
$ ng new < application-name > [options]
It's that easy.
# navigate to the root directory of your app, and run
$ ng serve[options]
# Open a browser and navigate to localhost:4200
Too much to show in a slide.
Let's checkout the project app 0-app-scaffolding.
So, let's get started with our app.
# Syntax: ng generate <item> <name> [options]
$ ng generate component key-manager
# Abbreviated syntax: ng g c <name> [options]
$ ng g c key-manager
See it work
Let's walk the code that demonstrates the two-way property-binding pattern.
Here is our task list for step two:
Here's what we're going to build 4203
$ ng generate component header
$ ng g c cuisine-type-list
$ npm install bootstrap --save
$ npm install font-awesome --save
Let's checkout the code.
Here's the behavior we we're looking for: 4204
We have a problem with our cuisine-type list that we need to resolve.
$ ng generate service cuisine-type --flat true
Review the the code.
We need to create console that will support both search and map visualizations, but first will add routing, another service and a few more components. Here is what we're trying to accomplish 4206.
$ ng g c console
$ ng g c search-panel
$ ng g c map-panel
$ ng g s yelp --flat true
Let's see the code.
We need components for our search and to build out the Yelp service to manage our API requests.
This is the functionality we want to create: 4207.
At the time this app was developed the Yelp Fusion API did not support CORS, preventing calls from client-side apps. To enable API access, a simple Yelp proxy is included in this repository.
$ ng g c search-control
$ ng g c search-results
Establishing communication between services and components is trivial matter with RxJS Observables
Let's see how we manage code state.Alright, we have a functioning app. Now let's add a useful visualization, so we can figure out how to get to the restaurant. To bring the ArcGIS API for JavaScript into Angular, we need the esri-loader.
$ npm install --save esri-loader
$ npm install --save @types/arcgis-js-api
# after installation
# add "types": ["arcgis-js-api"] to tsconfig.app.json
# add "types": ["arcgis-js-api"] to tsconfig.spec.json
import { loadModules } from 'esri-loader';
...
loadModules([
'esri/Map', 'esri/views/MapView', 'esri/Graphic'
])
.then(([EsriMap, EsriMapView, Graphic]) => {
// Work with your map
...
});
Sean Olson
seanolson-io