GithubHelp home page GithubHelp logo

esri / angular-esri-map Goto Github PK

View Code? Open in Web Editor NEW
213.0 53.0 107.0 3.52 MB

A collection of directives to help you use Esri maps and services in your Angular applications

Home Page: https://esri.github.io/angular-esri-map/

License: Apache License 2.0

JavaScript 50.18% HTML 47.94% Shell 0.46% CSS 1.42%
web-development javascript angular arcgis esri

angular-esri-map's Introduction

angular-esri-map

The angular-esri-map repository is now retired and is now archived (November 2020). It started in Long Term Maintenance mode on July 1, 2018.

Do you have a question related to JavaScript that isn’t specific to Angular? Post these questions in the GeoNET forum for the ArcGIS API for JavaScript.

Please take a look at these modern alternatives:

  • Esri-loader - A tiny library to help load ArcGIS API for JavaScript modules in non-Dojo applications.
  • Arcgis-webpack-plugin – A webpack wrapper for the ArcGIS API for JavaScript.
  • Angular-cli-esri-map – A repo that demos using the ArcGIS API for JavaScript in Angular 9+ applications.

A collection of directives to help you use Esri maps and services in your AngularJS v1.x applications.

These directives can be used as-is if your mapping needs are simple, or as reference examples of the patterns that you can use to write your own directives that use the ArcGIS API for JavaScript. Read more...

Table of Contents

Getting Started

Here are examples and guides showing how you can use this module to bring Esri maps into your own AngularJS v1.x applications.

Quick Start

To use these directives in your own AngularJS v1.x application, first install the module as a dependency using any of the following methods.

<!-- load angular-esri-map from CDN -->
<script src="https://unpkg.com/angular-esri-map@2"></script>
# OR install via bower
bower install angular-esri-map

# OR install via npm
npm install angular-esri-map

Alternatively, you can clone or download this repo and copy the desired module file (angular-esri-map.js or angular-esri-map.min.js) into your application.

Once you've added the module to your application, you can refer the sample code below to use the <esri-scene-view> directive. If you have downloaded or installed locally, point to the location of the module file in your environment (instead of CDN) and load the page in a browser.

App

<!DOCTYPE html>
<html ng-app="esri-map-example">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">

        <title>AngularJS Esri Quick Start</title>

        <link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
        <style type="text/css">
            html, body, .esri-view {
                padding: 0;
                margin: 0;
                height: 100%;
                width: 100%;
            }
        </style>
    </head>
    <body ng-controller="MapController as vm">
        <esri-scene-view map="vm.map" view-options="{scale: 50000000, center: [-101.17, 21.78]}">
        </esri-scene-view>

        <!-- load Esri JSAPI -->
        <script src="https://js.arcgis.com/4.8/"></script>
        <!-- load AngularJS -->
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.js"></script>
        <!-- load angular-esri-map -->
        <script src="https://unpkg.com/angular-esri-map@2"></script>

        <script>
            angular.module('esri-map-example', ['esri.map'])
                .controller('MapController', function(esriLoader) {
                    var self = this;
                    esriLoader.require(['esri/Map'], function(Map) {
                        self.map = new Map({
                            basemap: 'streets'
                        });
                    });
                });
        </script>
    </body>
</html>

See the documentation for examples and guides of how to use the other directives and services.

Lazy Loading of the ArcGIS API for JavaScript

If your application only shows a map under certain conditions you may want to lazy load the ArcGIS API for JavaScript. You can do this by calling the esriLoader.bootstrap() method. See the Lazy Load Patterns page for an example of how to do this.

Dependencies

At version 1.x, these directives and services require, at a minimum, AngularJS v1.3.0 and the ArcGIS API for JavaScript v3.12 (though most will work and are tested on v3.11).

For version 2.x, the ArcGIS API for JavaScript v4.0 is required.

See the compatibility table below for details.

angular-esri-map AngularJS ArcGIS API for JavaScript Notes
v1.0.0 v1.3 - v1.5 v3.12 - 3.21 Test coverage included for AngularJS v1.3.
v1.1.0 v1.3 - v1.5 v3.15 - 3.21
v1.1.8 v1.3+ v3.12 - 3.21 Due to a breaking change in controllers at AngularJS v1.6, e2e test coverage has been performed with v1.3, but will only continue with v1.6. See CHANGELOG.
v2.0.0 v1.3 - v1.5 v4.0 - v4.6 Test coverage included for AngularJS v1.3.
v2.0.2 v1.3+ v4.0 - v4.6 Due to a breaking change in controllers at AngularJS v1.6, e2e test coverage has been performed with v1.3, but will only continue with v1.6. See CHANGELOG.
v2.0.5 v1.3+ v4.6 - v4.8 Uses .when() instead of .then()

Resources

Websites

Presentations

What about Angular 2?

You can find up to date information on using the ArcGIS API for JavaScript in an Angular (2+) application at this Angular resources page.

What about Ionic?

Ionic is a mobile-ready implementation of Angular that is built on top of Cordova/PhoneGap. The coding patterns shown above can also be used with Ionic.

  • andygup/ionic2-esri-map: Example using ArcGIS API for JavaScript with Ionic2 using the angular2-esri-loader pattern with webpack.
  • jwasilgeo/ionic-esri-map: An Ionic1 app showing how to integrate a map using the angular-esri-map v1 pattern.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue. Thank you!

Contributing

Anyone and everyone is welcome to contribute. Please see our guidelines for contributing.

Development Instructions

Make sure you have Node and Gulp installed.

  1. Fork and clone this repo
  2. cd into the angular-esri-map folder
  3. Install the dependencies with npm install
  4. run gulp from the command line. This will run the linting and build commands and then start a local web server hosting the application under the docs folder
  5. Modify the source files (under src) and test pages (under test). Test pages are served along with the docs site when you run the gulp task and are accessible from the root (i.e. https://localhost:9002/simple-map.html).
  6. Make a pull request to contribute your changes

Licensing

Copyright 2014 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

https://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-esri-map's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-esri-map's Issues

Update esriMap listeners for continuous map extent information?

What if we were to add another (or replace) map event listener to esriMap, perhaps:

map.on('pan,zoom-end', function(e){...});

Instead of waiting for a 1-time extent-change when the user is done panning or zooming, how about getting continuous feedback on the extent object?

My very brief trial of this still needs some massaging to get it right:

  • it doesn't play nice with the $scope.center just yet, but seems fine when extentChange function binding is wired up
  • any potential for performance issues sneaking in?
  • if this is worth it, wanted to wait until any ongoing changes to esriMap get settled

continuous-extent-change

Nothing pressing here, but a potential nice-to-have for the the Map events and No Basemap demos (and maybe the others, if bullet point 1 is addressed). I'll be the 1st to admit that it's information overload for the user, but, you know, AngularJS folks like seeing things change and update ⚡ fast. 😄

Add more required modules from ESRI

Hello,
I have a question ..
How can i add more required modules from ESRI ..
Something like : ( esri/symbols/SimpleMarkerSymbol ) ..
and How can i implement map function such as : ( disableScrollWheelZoom() ) ?

test on most recent versions of angular

For each of the following, update the docs to load that version of angular, test, and commit:

  • 1.3.17
  • 1.4.4

Update the README to indicate that the module has been tested on 1.2,x, 1.3.x, and latest of 1.4.x

Best to do this after #66

Move core services (esriLoader) to own module ('esri.core')?

I want to enable the "roll your own custom map directive" pattern (as demonstrated in https://github.com/tomwayson/angular-parcel-map), as this will make it easier to spin up gists/fiddles/repos that demonstrate how to use newer angular 1.x patterns (controllerAs, bindToController, using a module loader like browserify, and ES6) that help prepare for 2.0.

At the same the community is continuing to build out the declarative mapping directives here. I want to encourage that w/o causing those that just need the esriLoader for their own custom directive to have to deal w/ the increasing complexity and versions that come w/ all those community contributions.

I'm thinking the "core" is pretty much just the esriLoader at this point. That could be made into it's own angular module ("esri.core") and the "esri.map" module could declare that as a dependency.

Thoughts? Feelings?

Call legend AFTER layers are done loading

How should we modify this code to force the legend directive to not run until after all the layers have been added to the map? I'm getting an issue where the "layerInfos" property is not filled at the time the legend directive fires because the map layers are not yet added to the map. I'm not sure how to delay the legend directive until the layers are done loading.

Identify example?

Is there an example of using an identifyTask similar to how the FeatureLayer directive is done?

I was hoping to make an angular directive that would look something like this in the html:
<esri-map> <esri-identify-task url="myurl" layerIDs="[0,3]" infoWindowTemplate="html template here"></esri-identify-task> </esri-map>

I am trying to modify the "FeatureLayer" directive to handle an identify task instead, but since an identify task doesn't "fire" when the map is loaded, the architecture seems a bit different. Is there an example that would show how to wire up the identify task to the map click event using the angular style?

Re size the popup

In the sample Webmap you have a popup available, but if you re size the application the map responds to different screen size but the popup looks like has a fixed size. Is there a way to code the popup that it would also reside based on the screen change.

Setup for gulp serve

Add browser-sync and re-org the project so you can run it out of any folder and don't need to configure a web server.

Makes it easier to "jump into" and get going.

esri map inside angular-ui boostrap tab always 400x400 pixels

Hi,
first, thank you for providing guidance and examples on how to use Esri's map control with AngularJS. While we are not using angular-esri-map directly, we inspired our code from it.
We are seeing a weird issue when putting the custom map directive inside a tab from angular-ui/boostrap. The map seems to default to 400px by 400px if inside a tab (inside a tabset).

I created a simple plunk to show the issue. If you click on the top links, it will switch between views and you can see that the top map, inside the tabset and tab combination is not taking the full width of the div like the one below (using the manual version of the tabset).
I am still new to plunker and angularJS, so I don't know why the app is not starting directly on the #/map1 url, I set the otherwise() to #/map1. However, if you were to open it in a separate window, select either map1 or map2 tabs, then hit full-refresh (as in Ctrl+F5), you will see that the map loads properly on the first load, but subsequent change of tabs will cause the new map to be reset to 400x400.

This could be a combination of many things (ngView, ngRoute, ui.bootstrap, map), but I was hoping you could provide us with some info as to what can cause the map the reset itself to 400x400 so we can root cause which other component is at fault here.

Regards,

Eric.

How to load maps from a mapserver?

Sorry if this is obvious but I'm relatively new to ESRI, I was wondering how I could load a map from a map server as opposed to a feature from a feature server.

Basically, if I could add a ArcGISDynamicMapServiceLayer through the controller or the directive, it'd be great.

Is this possible?

dojoLoader multiple define issue

As my web app has grown I have started seeing "Error: multipleDefine { src: 'dojoLoader' ....." errors on page load. The particular module that fails changes, but the result is the same. I can't use that module where I need to because it fails to load.

I have tried using require['esri/xxx'] exclusively. I have tried using esriLoader('esri/xxx') exclusively. I have tried a combination of the two. Same result. I even tried running a script on page load, and throwing in every module I want to use. Still I occasionally get this 'dojoLoader' error, and my page fails due to missing dependencies. Even if I catch the error, I am not sure how to gracefully retry.

I do not think I am doing anything too complex. I am using the 'esriMap' directive and the esriFeatureLayer directive as is. I created two more directives to use the esri KMLLayer and esri GraphicsLayer modules. Basically I changed FeatureLayer to KMLLayer or GraphicLayer, and in my custom GraphicLayer I added some code to load my symbols and GIS data to display. I didn't add any additional code to the KMLLayer directive.

I am loading the esri js modules from "http://js.arcgis.com/". I tried v3.12 and v3.13. I think hosting the files myself as part of my web app helps, but I would rather avoid that if at all possible.

In total I'm calling require or esriLoader from 5 places (EsriMap, EsriFeatureLayer, EsriKmlLayer, EsriGraphicLayer). The errors do not always occur, but when they do my page is unusable. A page refresh helps. The problem appears to happen more frequently when I have the Chrome developer tools open.

Do you have any suggestions here? I need dojoLoader to load all my modules correctly when the page loads, every time. This map is a small part of a larger angular application so I would prefer to use the angular framework here and wrap the ESRI modules. I have found other examples online for doing so, but your package has been the easiest to integrate, and up until this dojoLoader problem been exactly what I need.

Thank you for any help.

remove derived files from repo and add them to .gitignore

files generated by gulp (like angular-esri-map.js and angular-esri-map.min.js) should not be tracked by git, as they can be recreated locally by gulp at any time

having them in the repo makes it more difficult to merge and rebase branches, as you have to solve the same code conflicts in several files

I understand that they need to be in the gh-pages branch so that the online demo works... we need to automate that in the gulp build process

what do you think?

esrilegend.js not found in gulp

gulpfile.js looks for esriLegend.js. However, the file name is actually esrilegend.js. This leads to failures to include this directive in gulp on systems with case-sensitive filenames.

How to use our own basemap?

How would I modify this to use our own basemap? I have tried the following, but it results in an error:

"Uncaught TypeError: Cannot read property 'query' of null"

I have modified the esriMap directive as follows just to try forcing it to the new basemap:

Inside the controller, I have the following code:

require(['esri/map', 'esri/arcgis/utils', 'esri/basemaps'], function (Map, arcgisUtils, esriBasemaps) {
                    esriBasemaps.mcgiStreet = {
                        baseMapLayers: ['http://ourserverhere/arcgis/rest/services/BaseMap/StreetMap_tpt/MapServer'],
                        thumbnailUrl: 'http://servername.fqdn.suffix/images/thumbnail_2014-11-25_61051.png',
                        title: "Streetmap Transparent"
                    };

And then further down where the basemap is set, I have the following:

mapOptions.basemap = "mcgiStreet";

This is based off the example using the basemaps select box, and info from the following URL:
https://developers.arcgis.com/javascript/jsapi/esri.basemaps-amd.html

I'm relatively new to angular so I could be doing something wrong that is quite simple. Thank you for any help you can provide.

Add a legend to the web map example

Also use the load event instead of esriRegistry to get a handle to the map object.

Updating the example w/ these changes will help me verify a couple of things that I'm not sure are currently working w/ the web map:

  • will load event even fire if using a web map?
  • should we be setting the esriMap directive's layerInfos using arcgisUtils.getLegendLayers(response) (as shown in this sample) after loading from a web map (regardless if the page includes a legend)?

I think the best case scenario right now would be that it shows all layers in the legend. Worst case would be that the legend doesn't even work.

Add integration tests

Using Protractor, initial work to add some integration tests has started on the integration-testing branch.

  • added initial protractor scaffolding to the repo (see test/e2e dir)
  • worked out some basic (and fairly raw) integration testing against test/simple-map.html
  • added a new gulp test task

@tomwayson: any feedback, as well as jumping on this branch and pushing changes, is most welcome! Thanks.

Supporting Lazy Loading of Dojo/ESRI Javascript API

Is there any interest in creating the functionality to defer loading of Dojo/Digit and all of the ESRI modules? I have a use case within a SPA to only load ArcGIS maps only if certain conditions are met. By defering loading, it would remove the need to require all angular-esri-map (Dojo, Dijit resources until needed).

angular-google-maps moved to this paradigm. If there is interest I can start PR for it.

Make a "pretty" home page

The initial landing page should be something more than an unstyled list of links to the individual examples. Should add bootstrap and example map/code, along with links to individual examples. This could be basis for the gh-pages branch.

document lazy loading of JSAPI

Thanks to @ScottONeal we now have lazy loading of the JSAPI. Need to document this, and some way to demonstrate (can't demo in existing examples page b/c JSAPI is already loaded on the page). Maybe just a link to the test page.

Map is always 400px high

The map is always 400px high. I've tried setting the following in my CSS but it makes no difference:

html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }

Any ideas? Is there a property on the map for height that I can pass to it? I didn't see anything in the ESRI JS API for that, but perhaps I missed it.

I looked at issue #42 but I'm not sure that relates to my problem. When I comment out my bootstrap css the map still displays at 400px high. I'd like to get it to be a full screen map.

Adding Points of locations to the Esri map

I'm trying to make a application so I can put my Spatial data on in my application with Points.

Now i have the problem that when i try to add these points by adding them to the map through graphics I get the error that it doesn't know the graphics function however i added esri/graphic to the require..

Any idea how I can fix this, I'm kinda new to the whole AngularJS.

Thanks

Should esriLoader.require()'s promise resolve an object instead of an array

I know we've already had this discussion but I wonder if the promise was resolved with an object that contained the required modules as properties if it would be easier to work with instead of an array. The only trick would be making sure there are no name conflicts in the prorperties, but we could just replace the / characters with . characters.

To me, this:

esriLoader.require(['esri/Map', 'esri/layers/FeatureLayer']).then(function(modules) {
  var map = new modules.esri.Map(...);
  var layer = new modules.esri.layers.FeatureLayer(...);
});

Is better than this:

esriLoader.require(['esri/Map', 'esri/layers/FeatureLayer']).then(function(modules) {
  var Map = modules[0];
  var FeatureLayer = modules[1];
  var map = new Map(...);
  var layer = new FeatureLayer(...);
});

Just want to get input on this before #69.

AngularJS ESRI TOC?

I am wondering if there is an angular js ESRI TOC similar to this one:

http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/docs/toc/examples.html

I am looking to create a TOC that is similar but was hoping for some guidance on where to start, Originally i thought perhaps I could make a directive that would be a child of the legend directive, but there are features in the example TOC that I'd like to have that I'm not sure will easily translate if I do it that way (like graying out layers that are out of scale).

Do you have any suggestions on on to proceed or any examples that would be best to start from? Thanks again for your help! =)

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.