GithubHelp home page GithubHelp logo

slamj1 / angular-cli-esri-map Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esri/angular-cli-esri-map

0.0 2.0 0.0 839 KB

Example Angular component for building mapping applications with the ArcGIS API for JavaScript

Home Page: https://stackblitz.com/edit/angular-cli-esri-map2?file=src/main.ts

License: Apache License 2.0

CSS 3.95% HTML 16.16% TypeScript 79.90%

angular-cli-esri-map's Introduction

angular-cli-esri-map

This tutorial shows you how to integrate the ArcGIS API for JavaScript, which is an enterprise geospatial API, using Angular CLI.

This repo demonstrates implementing a simple, extensible mapping component. Use this repo as a building block for adding in more advanced capabilities.

Dependencies

This repo has the following dependencies:

Build your project

If you are just getting started with Angular development, listed below are the steps for creating a simple Hello World mapping application with Angular CLI.

Once you are comfortable with the getting started steps, feel free to explore building out the app using the rest of the code in this repo.

There is also a getting started video if that's easier: https://www.youtube.com/watch?v=ZEH9kOwDgx0.

Clone or download this repo

  git clone https://github.com/andygup/angular-cli-esri-map.git

Install Angular CLI and generate a new project

Make sure you have Angular CLI installed. See the instructions here: https://cli.angular.io/

Install esri-loader and the Esri TypeScript types

You need esri-loader because it is a low level service that helps load ArcGIS JavaScript API modules (v3.x or v4.x) in non-Dojo applications.

And, the ArcGIS JavaScript TypeScript type definitions can be found here. Note: using the Esri Types is optional. However, you'll need to modify this repos code to work without Types.

  npm install --save esri-loader
  npm install --save @types/arcgis-js-api

Generate the scaffolding for your mapping component

  ng generate component esri-map

  # or you can also use shorthand
  ng g component esri-map

Copy the contents from the angular-cli-esri-map/src/app/esri-map folder into your new esri-app/src/app/esri-map directory.

Copy the app.components contents from angular-cli-esri-map/src/app into your new esri-app/src/app/ directory.

  • In tsconfig.app.json add "types": ["arcgis-js-api"].

  • In tsconfig.spec.json add "types": ["arcgis-js-api"].

Make sure the mapping app runs

Now run the following command and you should see our mapping appear on the page.

  ng serve

Navigate to http://localhost:4200/ to see the app. The app will automatically reload if you change any of the source files. If you see the mapping app and it runs without errors then you have been successful with getting started. You can go ahead and shutdown ng serve with a Control C anytime you wish.

Build our spec and run it to make sure everything is good

Copy app.component.spec.ts into the /app directory.

  import { TestBed, async } from '@angular/core/testing';
  import { AppComponent } from './app.component';
  import { EsriMapComponent } from './esri-map/esri-map.component';

  describe('AppComponent', () => {
    beforeEach(async(() => {
      TestBed.configureTestingModule({
        declarations: [
          AppComponent,
          EsriMapComponent
        ],
      }).compileComponents();
    }));
    it('should create the app', async(() => {
      const fixture = TestBed.createComponent(AppComponent);
      const app = fixture.debugElement.componentInstance;
      expect(app).toBeTruthy();
    }));
    it(`should have as title 'app'`, async(() => {
      const fixture = TestBed.createComponent(AppComponent);
      const app = fixture.debugElement.componentInstance;
      expect(app.title).toEqual('app');
    }));
    it('should render title in a h1 tag', async(() => {
      const fixture = TestBed.createComponent(AppComponent);
      fixture.detectChanges();
      const compiled = fixture.debugElement.nativeElement;
      expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
    }));
  });

Now lets see if the test spec passes by running:

  ng test

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Licensing

Copyright 2019 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

angular-cli-esri-map's People

Contributors

andygup avatar angular-cli avatar haidarz avatar ixshel avatar jwasilgeo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.