Skip to content

Commit

Permalink
Formatting Code
Browse files Browse the repository at this point in the history
  • Loading branch information
oppoudel committed Aug 9, 2017
1 parent 72fa70c commit 271c298
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 69 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.formatOnSave": false
}
157 changes: 88 additions & 69 deletions src/components/esrimap.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,97 @@
import config from '@/config/config'
import { store } from '@/store/store'
export const createMap = function (loader, router, title) {
const esriLoader = loader
esriLoader.dojoRequire([
'esri/core/urlUtils',
'esri/core/watchUtils',
'esri/views/MapView',
'esri/Map',
'esri/layers/VectorTileLayer',
'esri/layers/Layer',
'esri/widgets/Expand',
'esri/widgets/Legend',
'esri/widgets/LayerList',
'esri/widgets/Search'
], (urlUtils, watchUtils, MapView, Map, VectorTileLayer, Layer, Expand, Legend, LayerList, Search) => {
const urlObject = urlUtils.urlToObject(window.location.href)
const center = (urlObject.query.center.split(',')).map(element => parseFloat(element))
const ids = (urlObject.query.ids.split(','))
const zoom = urlObject.query.zoom
const map = new Map()
const tileLyr = new VectorTileLayer({
url: config.tileLayerURL
})
map.add(tileLyr)
const view = new MapView({
map: map,
container: 'viewDiv',
zoom: zoom,
center: center
})
ids.forEach(function (id) {
Layer.fromPortalItem({
portalItem: {
id: id
}
}).then(function (layer) {
map.add(layer)
esriLoader.dojoRequire(
[
'esri/core/urlUtils',
'esri/core/watchUtils',
'esri/views/MapView',
'esri/Map',
'esri/layers/VectorTileLayer',
'esri/layers/Layer',
'esri/widgets/Expand',
'esri/widgets/Legend',
'esri/widgets/LayerList',
'esri/widgets/Search'
],
(
urlUtils,
watchUtils,
MapView,
Map,
VectorTileLayer,
Layer,
Expand,
Legend,
LayerList,
Search
) => {
const urlObject = urlUtils.urlToObject(window.location.href)
const center = urlObject.query.center.split(',').map(element => parseFloat(element))
const ids = urlObject.query.ids.split(',')
const zoom = urlObject.query.zoom
const map = new Map({
basemap: 'topo-vector'
})
})
view.then(() => {
const legend = new Legend({
view: view,
container: document.createElement('div')
const view = new MapView({
map: map,
container: 'viewDiv',
zoom: zoom,
center: center
})
const layerList = new LayerList({
view: view,
container: document.createElement('div')
ids.forEach(function (id) {
Layer.fromPortalItem({
portalItem: {
id: id
}
}).then(function (layer) {
map.add(layer)
})
})
const legendExpand = new Expand({
view: view,
content: legend.domNode,
expandIconClass: 'esri-icon-collection',
expandTooltip: 'Legend'
view.then(() => {
const legend = new Legend({
view: view,
container: document.createElement('div')
})
const layerList = new LayerList({
view: view,
container: document.createElement('div')
})
const legendExpand = new Expand({
view: view,
content: legend.domNode,
expandIconClass: 'esri-icon-collection',
expandTooltip: 'Legend'
})
const layersExpand = new Expand({
view: view,
content: layerList.domNode,
expandIconClass: 'esri-icon-layer-list',
expandTooltip: 'Layers'
})
view.ui.add(layersExpand, 'top-right')
view.ui.add(legendExpand, 'top-right')
})
const layersExpand = new Expand({
view: view,
content: layerList.domNode,
expandIconClass: 'esri-icon-layer-list',
expandTooltip: 'Layers'
const searchWidget = new Search({
view: view
})
view.ui.add(layersExpand, 'top-right')
view.ui.add(legendExpand, 'top-right')
})
const searchWidget = new Search({
view: view
})
view.ui.add(searchWidget, {
position: 'top-left',
index: 0
})
watchUtils.whenTrue(view, 'stationary', () => {
let center = [view.center.longitude.toFixed(3), view.center.latitude.toFixed(3)].toString()
let zoom = view.zoom
router.push({name: 'map', query: {mapTitle: store.state.route.query.mapTitle, zoom: zoom, ids: ids.join(','), center: center}})
})
})
view.ui.add(searchWidget, {
position: 'top-left',
index: 0
})
watchUtils.whenTrue(view, 'stationary', () => {
let center = [view.center.longitude.toFixed(3), view.center.latitude.toFixed(3)].toString()
let zoom = view.zoom
router.push({
name: 'map',
query: {
mapTitle: store.state.route.query.mapTitle,
zoom: zoom,
ids: ids.join(','),
center: center
}
})
})
}
)
}

0 comments on commit 271c298

Please sign in to comment.