From e80bbeddd884f39313f196b0b88d79f971652f90 Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Tue, 14 Nov 2017 10:17:14 -0800 Subject: [PATCH 1/4] install ember-esri-loader --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4ce6d3c..bfaa801 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,9 @@ "ember-cli-qunit": "^4.0.0", "ember-cli-shims": "^1.1.0", "ember-cli-sri": "^2.1.0", - "ember-cli-uglify": "^1.2.0", - "ember-data": "~2.14.9", + "ember-cli-uglify": "^2.0.0", + "ember-data": "~2.16.2", + "ember-esri-loader": "^0.2.0", "ember-export-application-global": "^2.0.0", "ember-fetch": "^3.4.3", "ember-load-initializers": "^1.0.0", From c611f8c9d95b7b5ca043a49e4b70363d46fe5580 Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Tue, 14 Nov 2017 11:26:32 -0800 Subject: [PATCH 2/4] add web-map component and map route --- app/components/web-map.js | 40 ++++++++++++++++++++ app/router.js | 1 + app/routes/map.js | 4 ++ app/styles/app.css | 6 +++ app/templates/index.hbs | 1 + app/templates/map.hbs | 2 + tests/integration/components/web-map-test.js | 24 ++++++++++++ tests/unit/routes/map-test.js | 11 ++++++ 8 files changed, 89 insertions(+) create mode 100644 app/components/web-map.js create mode 100644 app/routes/map.js create mode 100644 app/templates/map.hbs create mode 100644 tests/integration/components/web-map-test.js create mode 100644 tests/unit/routes/map-test.js diff --git a/app/components/web-map.js b/app/components/web-map.js new file mode 100644 index 0000000..02df752 --- /dev/null +++ b/app/components/web-map.js @@ -0,0 +1,40 @@ +import Component from '@ember/component'; +import { inject as service } from "@ember/service"; + +export default Component.extend({ + + classNames: 'web-map', + + esriLoader: service('esri-loader'), + + // once we have a DOM node to attach the map to... + didInsertElement () { + this._super(...arguments); + // load the map modules + this.get('esriLoader').loadModules(['esri/views/MapView', 'esri/WebMap']) + .then(modules => { + if (this.get('isDestroyed') || this.get('isDestroying')) { + return; + } + const [MapView, WebMap] = modules; + // load the webmap from a portal item + const webmap = new WebMap({ + portalItem: { // autocasts as new PortalItem() + id: this.itemId + } + }); + // Set the WebMap instance to the map property in a MapView. + this._view = new MapView({ + map: webmap, + container: this.elementId + }); + }); + }, + + // destroy the map before this component is removed from the DOM + willDestroyElement () { + if (this._view) { + delete this._view; + } + } +}); diff --git a/app/router.js b/app/router.js index cdc2578..ecccfbc 100644 --- a/app/router.js +++ b/app/router.js @@ -7,6 +7,7 @@ const Router = Ember.Router.extend({ }); Router.map(function() { + this.route('map'); }); export default Router; diff --git a/app/routes/map.js b/app/routes/map.js new file mode 100644 index 0000000..6c74252 --- /dev/null +++ b/app/routes/map.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default Route.extend({ +}); diff --git a/app/styles/app.css b/app/styles/app.css index e69de29..215dba2 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -0,0 +1,6 @@ +/* esri styles */ +@import url('https://js.arcgis.com/4.5/esri/css/main.css'); + +.web-map { + height: 400px; +} diff --git a/app/templates/index.hbs b/app/templates/index.hbs index 01ead40..cf78bdd 100644 --- a/app/templates/index.hbs +++ b/app/templates/index.hbs @@ -7,3 +7,4 @@

# of Public Repos: {{model.public_repos}}

+

{{link-to 'Map' 'map'}}

diff --git a/app/templates/map.hbs b/app/templates/map.hbs new file mode 100644 index 0000000..a153660 --- /dev/null +++ b/app/templates/map.hbs @@ -0,0 +1,2 @@ +

Map View

+{{web-map itemId="f2e9b762544945f390ca4ac3671cfa72"}} diff --git a/tests/integration/components/web-map-test.js b/tests/integration/components/web-map-test.js new file mode 100644 index 0000000..d6989bd --- /dev/null +++ b/tests/integration/components/web-map-test.js @@ -0,0 +1,24 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('web-map', 'Integration | Component | web map', { + integration: true +}); + +test('it renders', function(assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{web-map}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#web-map}} + template block text + {{/web-map}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); diff --git a/tests/unit/routes/map-test.js b/tests/unit/routes/map-test.js new file mode 100644 index 0000000..6f01ead --- /dev/null +++ b/tests/unit/routes/map-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:map', 'Unit | Route | map', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); From 37b17ad933116d2c09d925c722e4e96df96e2bb2 Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Fri, 17 Nov 2017 11:40:52 -0800 Subject: [PATCH 3/4] pass require function name to fastboot via enviroment config --- config/environment.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/environment.js b/config/environment.js index f3ef9a6..a096e38 100644 --- a/config/environment.js +++ b/config/environment.js @@ -21,6 +21,12 @@ module.exports = function(environment) { APP: { // Here you can pass flags/options to your application instance // when it is created + }, + + fastboot: { + sandboxGlobals: { + requireFunctionName: 'equireray' + } } }; From c4049cc6e9ba96cf2f539633c8882bf5cb5cf77c Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Fri, 17 Nov 2017 16:10:03 -0800 Subject: [PATCH 4/4] get ember-esri-loader and ember-cli-fastboot from repos instead of npm link --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bfaa801..f5e1b96 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "ember-cli-babel": "^6.3.0", "ember-cli-dependency-checker": "^1.3.0", "ember-cli-eslint": "^4.0.0", - "ember-cli-fastboot": "^1.1.0", + "ember-cli-fastboot": "tomwayson/ember-cli-fastboot#test\/require-fn-name", "ember-cli-htmlbars": "^2.0.1", "ember-cli-htmlbars-inline-precompile": "^0.4.3", "ember-cli-inject-live-reload": "^1.4.1", @@ -31,7 +31,7 @@ "ember-cli-sri": "^2.1.0", "ember-cli-uglify": "^2.0.0", "ember-data": "~2.16.2", - "ember-esri-loader": "^0.2.0", + "ember-esri-loader": "esri/ember-esri-loader#fastboot", "ember-export-application-global": "^2.0.0", "ember-fetch": "^3.4.3", "ember-load-initializers": "^1.0.0",