diff --git a/.gitignore b/.gitignore index 8e39775..1e34bde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # built files under app folder -app/scripts +docs/lib # Logs logs diff --git a/app/index.html b/app/index.html deleted file mode 100644 index 70056e5..0000000 --- a/app/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - Angular Esri Map Examples - - - - - - - - -
-
- -

angular-esri-map

-
- -
-

<esri-map/>

-

Examples showing how to use the angular-esri-map directives.

-

While these directives can be used, we intend this to be used as an example for building your own - application-specific directives.

-
- -
-
-

Simple map

-

Simplest possible map - simply setting the

- -

Webmap

-

Loading webmaps from ArcGIS Online

- -

Set basemap

-

Shows how to use angular binding to link a select list to the basemap property of the map.

- -

Set map center and zoom

-

Demonstrates two-way binding of the center, and zoom properties.

-
- -
-

Feature layers

-

Loads two feature layers into the map.

- -

Legend

-

Add a legend via to the map. Also shows a directive that is not an element.

- -

Map events

-

Shows how to listen for events raised by the map directive.

-
-
- - -
-
-

Zen of Directives and Maps

-

If you've read this far, you will have noticed that these are very, very simple - directives. For example - there is no way to apply styles to the feature layers, nor - is there support for any of the 20+ other layers supported by the Esri Javascript API. This was not and oversight, it was by design.

-

We feel that the value of directives (or web components for that matter) is to - package up complex components, exposing a limited, simple declarative interface - as html-elements & attributes. Attempting to encapsulate all the layers, renderers, symbols and events of the JS API in a set of directives would simply add more bulk to the javascript, and create another complex api to learn and support. -

-

Roll Your Own Directives

-

We believe that you will have the best success integrating maps with - your angular applications if you build directives that focus on your problem domain. -

-

For example - suppose you are building an application for a local government. There is a very good chance that you would be integrating a few standard types of maps. Using the examples provided in this repo you could create directives like...

-

-<parcel-map pin="ABC123"></parcel-map>
-<lot-layout-map lot="93920-A-23"></lot-layout-map>
-<workorder-map order="10-31-14-002"></workorder-map>
-            
-

These directives could be easily integrated into any views in the over-arching application, or even shared across a suite of applications. -

- -

Some thoughts on Angular...

-

At Esri we use a number of differnt javascript application frameworks, including Angular. While we find that using Angular can lead to huge productivity increases, and massively streamlined code - it is worth noting that Angular is a silver bullet for all types of web applications. -

-

Where we have seen the greatest benefit is in situations where the majority of the application functionality is "forms-over-data", with a few maps added in. Similarly, when we have tried to use Angular on single-page, full-screen mapping applications, we have found ourselves working against the framework. -

-

So, as the old saying goes use the right tool for the job!

-
-
- - - - -
- - - diff --git a/docs/app/about/about.html b/docs/app/about/about.html new file mode 100644 index 0000000..43fef48 --- /dev/null +++ b/docs/app/about/about.html @@ -0,0 +1,29 @@ +
+
+

Zen of Directives and Maps

+

You have probably noticed that these are very, very simple directives. For example - there is no way to apply styles to the feature layers, nor is there support for any of the 20+ other layers supported by the Esri Javascript API. This was not and oversight, it was by design.

+

We feel that the value of directives (or web components for that matter) is to package up complex components, exposing a limited, simple declarative interface as html-elements & attributes. Attempting to encapsulate all the layers, renderers, symbols and events of the JS API in a set of directives would simply add more bulk to the javascript, and create another complex api to learn and support. +

+

Instead, we are providing a small set of re-usable directives. If your applicaiton has modest mapping needs, these directives may be useful as-is. If your application makes use of some of the more advanced features of the Esri JavaScript API, then the directives in this repo should demonstrate the patterns that will help you create your own directives.

+

Roll Your Own Directives

+

We believe that you will have the best success integrating maps with your angular applications if you build directives that focus on your problem domain. +

+

For example - suppose you are building an application for a local government. There is a very good chance that you would be integrating a few standard types of maps. Using the examples provided in this repo you could create directives like...

+

+<parcel-map pin="ABC123"></parcel-map>
+<lot-layout-map lot="93920-A-23"></lot-layout-map>
+<workorder-map order="10-31-14-002"></workorder-map>
+            
+

These directives could be easily integrated into any views in the over-arching application, or even shared across a suite of applications. +

+ +

Some thoughts on Angular...

+

At Esri we use a number of differnt javascript application frameworks, including Angular. While we find that using Angular can lead to huge productivity increases, and massively streamlined code - it is worth noting that Angular is a silver bullet for all types of web applications. +

+

Where we have seen the greatest benefit is in situations where the majority of the application functionality is "forms-over-data", with a few maps added in. Similarly, when we have tried to use Angular on single-page, full-screen mapping applications, we have found ourselves working against the framework. +

+

So, as the old saying goes + use the right tool for the job! +

+
+
diff --git a/docs/app/about/about.js b/docs/app/about/about.js new file mode 100644 index 0000000..7c18e48 --- /dev/null +++ b/docs/app/about/about.js @@ -0,0 +1,6 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('AboutCtrl', function($scope) { + $scope.$parent.page = 'about'; + }); diff --git a/docs/app/app.js b/docs/app/app.js new file mode 100644 index 0000000..c42ec6f --- /dev/null +++ b/docs/app/app.js @@ -0,0 +1,47 @@ +(function(angular) { + 'use strict'; + angular + .module('esri-map-docs', ['ngRoute', 'ngSanitize', 'esri.map']) + .config(function($routeProvider) { + $routeProvider + .when('/examples', { + templateUrl: 'app/examples/examples.html', + controller: 'ExamplesCtrl' + }) + .when('/examples/simple-map', { + templateUrl: 'app/examples/simple-map.html', + controller: 'SimpleMapCtrl' + }) + .when('/examples/feature-layers', { + templateUrl: 'app/examples/feature-layers.html', + controller: 'FeatureLayersCtrl' + }) + .when('/examples/web-map', { + templateUrl: 'app/examples/web-map.html', + controller: 'WebMapCtrl' + }) + .when('/examples/legend', { + templateUrl: 'app/examples/legend.html', + controller: 'LegendCtrl' + }) + .when('/examples/center-and-zoom', { + templateUrl: 'app/examples/center-and-zoom.html', + controller: 'CenterAndZoomCtrl' + }) + .when('/examples/basemap', { + templateUrl: 'app/examples/basemap.html', + controller: 'BasemapCtrl' + }) + .when('/examples/map-events', { + templateUrl: 'app/examples/map-events.html', + controller: 'MapEventsCtrl' + }) + .when('/about', { + templateUrl: 'app/about/about.html', + controller: 'AboutCtrl' + }) + .otherwise({ + redirectTo: '/examples' + }); + }); +})(angular); diff --git a/docs/app/examples/basemap.html b/docs/app/examples/basemap.html new file mode 100644 index 0000000..ee42ad1 --- /dev/null +++ b/docs/app/examples/basemap.html @@ -0,0 +1,17 @@ +

Basemap Example

+ + +

Basemap: + + Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}} +

+

Based on this sample.

diff --git a/docs/app/examples/basemap.js b/docs/app/examples/basemap.js new file mode 100644 index 0000000..c0ede23 --- /dev/null +++ b/docs/app/examples/basemap.js @@ -0,0 +1,14 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('BasemapCtrl', function($scope) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -31.036, + lat: 42.747 + }, + zoom: 3, + basemap: 'satellite' + }; + }); diff --git a/docs/app/examples/center-and-zoom.html b/docs/app/examples/center-and-zoom.html new file mode 100644 index 0000000..bdfe968 --- /dev/null +++ b/docs/app/examples/center-and-zoom.html @@ -0,0 +1,13 @@ +

Set Map Center and Zoom

+ + +

+ Lat: + Lng: + , Zoom: + + + +

diff --git a/docs/app/examples/center-and-zoom.js b/docs/app/examples/center-and-zoom.js new file mode 100644 index 0000000..5b44d66 --- /dev/null +++ b/docs/app/examples/center-and-zoom.js @@ -0,0 +1,31 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('CenterAndZoomCtrl', function($scope) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -122.45, + lat: 37.75 + }, + zoom: 12, + basemap: 'topo' + }; + $scope.cities = { + SanFrancisco: { + lng: -122.45, + lat: 37.75, + zoom: 10 + }, + NewYork: { + lng: -74.0059, + lat: 40.7127, + zoom: 12 + } + }; + $scope.zoomToCity = function(city) { + $scope.map.center.lat = city.lat; + $scope.map.center.lng = city.lng; + $scope.map.zoom = city.zoom; + } + }); diff --git a/docs/app/examples/examples.html b/docs/app/examples/examples.html new file mode 100644 index 0000000..d04c119 --- /dev/null +++ b/docs/app/examples/examples.html @@ -0,0 +1,37 @@ +
+

<esri-map/>

+

Examples showing how to use the angular-esri-map directives.

+
+
+
+

Simple map +

+

Simplest possible map - simply setting the

+ +

Webmap +

+

Loading webmaps from ArcGIS Online

+ +

Set basemap +

+

Shows how to use angular binding to link a select list to the basemap property of the map.

+ +

Set map center and zoom +

+

Demonstrates two-way binding of the center, and zoom properties.

+
+ +
+

Feature layers +

+

Loads two feature layers into the map.

+ +

Legend +

+

Add a legend via to the map. Also shows a directive that is not an element.

+ +

Map events +

+

Shows how to listen for events raised by the map directive.

+
+
diff --git a/docs/app/examples/examples.js b/docs/app/examples/examples.js new file mode 100644 index 0000000..f93780c --- /dev/null +++ b/docs/app/examples/examples.js @@ -0,0 +1,6 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('ExamplesCtrl', function($scope) { + $scope.$parent.page = 'examples'; + }); diff --git a/docs/app/examples/feature-layers.html b/docs/app/examples/feature-layers.html new file mode 100644 index 0000000..41a6e26 --- /dev/null +++ b/docs/app/examples/feature-layers.html @@ -0,0 +1,8 @@ +

Feature Layers Example

+ + + + + +

Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}}

+

Based on this JS Fiddle.

diff --git a/docs/app/examples/feature-layers.js b/docs/app/examples/feature-layers.js new file mode 100644 index 0000000..c9703b3 --- /dev/null +++ b/docs/app/examples/feature-layers.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('FeatureLayersCtrl', function($scope) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -122.676207, + lat: 45.523452 + }, + zoom: 12 + }; + }); diff --git a/docs/app/examples/legend.html b/docs/app/examples/legend.html new file mode 100644 index 0000000..7c61059 --- /dev/null +++ b/docs/app/examples/legend.html @@ -0,0 +1,16 @@ +

Legend Example

+ +
+
+ + + +
+
+

Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}}

+

Based on this sample.

+
+
+
+
+
diff --git a/docs/app/examples/legend.js b/docs/app/examples/legend.js new file mode 100644 index 0000000..ae8b134 --- /dev/null +++ b/docs/app/examples/legend.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('LegendCtrl', function($scope) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -96.53, + lat: 38.374 + }, + zoom: 13 + }; + }); diff --git a/docs/app/examples/map-events.html b/docs/app/examples/map-events.html new file mode 100644 index 0000000..46436db --- /dev/null +++ b/docs/app/examples/map-events.html @@ -0,0 +1,7 @@ +

Map Events Example

+ + + +

The map is + notloaded.

+

Extent: {{ map.extent.toJson() }}

diff --git a/docs/app/examples/map-events.js b/docs/app/examples/map-events.js new file mode 100644 index 0000000..10bc69f --- /dev/null +++ b/docs/app/examples/map-events.js @@ -0,0 +1,34 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('MapEventsCtrl', function($scope, esriRegistry) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -122.45, + lat: 37.75 + }, + zoom: 13, + loaded: false, + }; + // one way to get a reference to the map is to + // set a handler for the map directive's load attribute + $scope.mapLoaded = function(map) { + // now you have a reference to the map + // that you can do whatever you want with + console.log(map); + $scope.map.loaded = true; + }; + // another way is to set the register-as attribute on the directive + // and then use the esriRegistry to get the map by name + esriRegistry.get('myMap').then(function(map) { + map.on('click', function(e) { + console.log('map click', e); + }); + }); + // the map directive also exposes an extent-change attribute + $scope.extentChanged = function(e) { + // now you have a reference to the extent + $scope.map.extent = e.extent; + }; + }); diff --git a/docs/app/examples/simple-map.html b/docs/app/examples/simple-map.html new file mode 100644 index 0000000..3093872 --- /dev/null +++ b/docs/app/examples/simple-map.html @@ -0,0 +1,6 @@ +

Simple Map Example

+ + + +

Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}}

+

Based on this sample.

diff --git a/docs/app/examples/simple-map.js b/docs/app/examples/simple-map.js new file mode 100644 index 0000000..a474cca --- /dev/null +++ b/docs/app/examples/simple-map.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('SimpleMapCtrl', function($scope) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -122.45, + lat: 37.75 + }, + zoom: 13 + }; + }); diff --git a/docs/app/examples/web-map.html b/docs/app/examples/web-map.html new file mode 100644 index 0000000..9112bca --- /dev/null +++ b/docs/app/examples/web-map.html @@ -0,0 +1,17 @@ +

Webmap Example: {{itemInfo.item.title}} + + + +info + hide + + +

+
+ + + +

Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}}

+

+ +

+

Based on this sample.

diff --git a/docs/app/examples/web-map.js b/docs/app/examples/web-map.js new file mode 100644 index 0000000..f7caabd --- /dev/null +++ b/docs/app/examples/web-map.js @@ -0,0 +1,21 @@ +'use strict'; + +angular.module('esri-map-docs') + .controller('WebMapCtrl', function($scope, esriLoader, esriRegistry) { + $scope.$parent.page = 'examples'; + $scope.map = { + center: { + lng: -122.45, + lat: 37.75 + }, + zoom: 13 + }; + $scope.goToBookmark = function(bookmark) { + esriRegistry.get('myMap').then(function(map) { + esriLoader('esri/geometry/Extent').then(function(Extent) { + var extent = new Extent(bookmark.extent); + map.setExtent(extent); + }); + }); + }; + }); diff --git a/docs/images/jumbotron-background.jpg b/docs/images/jumbotron-background.jpg new file mode 100644 index 0000000..33b206a Binary files /dev/null and b/docs/images/jumbotron-background.jpg differ diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..023c116 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,67 @@ + + + + + + + Angular Esri Map + + + + + + + + + + + + + +
+
+ +

angular-esri-map

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/styles/narrow.css b/docs/styles/narrow.css similarity index 100% rename from app/styles/narrow.css rename to docs/styles/narrow.css diff --git a/app/feature-layers.html b/examples/feature-layers.html similarity index 97% rename from app/feature-layers.html rename to examples/feature-layers.html index bc78c22..8281a43 100644 --- a/app/feature-layers.html +++ b/examples/feature-layers.html @@ -24,7 +24,7 @@

Feature Layers Example

- + - + - + - + - + diff --git a/app/simple-map.html b/examples/simple-map.html similarity index 96% rename from app/simple-map.html rename to examples/simple-map.html index f528800..49b89a8 100644 --- a/app/simple-map.html +++ b/examples/simple-map.html @@ -21,7 +21,7 @@

Simple Map Example

- + - +