Skip to content

Commit

Permalink
upgrades mapboxgl-draw, extends map component, re: #4670
Browse files Browse the repository at this point in the history
  • Loading branch information
robgaston committed Jun 25, 2019
1 parent dd2c52e commit f90c9a8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions arches/app/media/css/arches.css
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ ul.tabbed-report-tab-list {
background: white;
border-left: 1px solid rgb(216, 216, 216);
padding: 16px;
overflow-y: scroll;
}

.map-card-sidepanel-header {
Expand Down
5 changes: 2 additions & 3 deletions arches/app/media/js/views/components/cards/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ define([
'knockout',
'viewmodels/card-component',
'views/components/map'
], function(ko, CardComponentViewModel) {
], function(ko, CardComponentViewModel, MapComponentViewModel) {
return ko.components.register('map-card', {
viewModel: function(params) {
this.map = ko.observable();

CardComponentViewModel.apply(this, [params]);
MapComponentViewModel.apply(this, [params]);
},
template: {
require: 'text!templates/views/components/cards/map.htm'
Expand Down
5 changes: 3 additions & 2 deletions arches/app/media/js/views/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ define([
}, arches.mapSources, params.sources);
var mapLayers = params.mapLayers || arches.mapLayers;

this.map = ko.isObservable(params.map) ? params.map : ko.observable();
this.basemaps = [];
this.overlays = ko.observableArray();
this.activeBasemap = ko.observable();
Expand Down Expand Up @@ -154,8 +155,6 @@ define([
};

this.setupMap = function(map) {
if (ko.isObservable(params.map)) params.map(map);

map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.addControl(new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
Expand All @@ -169,6 +168,8 @@ define([
style.layers = layers;
map.setStyle(style);
});

self.map(map);
};
};
ko.components.register('arches-map', {
Expand Down
7 changes: 1 addition & 6 deletions arches/app/templates/views/components/cards/map.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
{% load i18n %}

{% block form %}
<!-- ko component: {
name: 'arches-map',
params: {
map: map
}
} --> <!-- /ko -->
{% include 'views/components/map-editor.htm' %}
{% endblock form %}
10 changes: 10 additions & 0 deletions arches/app/templates/views/components/map-editor.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "views/components/map.htm" %}
{% load i18n %}

{% block tabs %}
{{ block.super }}
{% endblock tabs %}

{% block sidepanel %}
{{ block.super }}
{% endblock sidepanel %}
4 changes: 4 additions & 0 deletions arches/app/templates/views/components/map.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<div class="map-card-wrapper">
<div class="map-card-sidebar">
{% block tabs %}
<div class="map-card-sidebar-tab" data-bind="click: function() {
toggleTab('basemap');
}, css: {
Expand All @@ -26,9 +27,11 @@
<i class="fa fa-list-alt"></i>
{% trans "Legend" %}
</div>
{% endblock tabs %}
</div>
<!--ko if: activeTab() -->
<div class="map-card-sidepanel">
{% block sidepanel %}
<!--ko if: activeTab() === 'basemap' -->
<h4 class="map-card-sidepanel-header" data-bind="click: hideSidePanel">
{% trans "Basemaps" %}
Expand Down Expand Up @@ -88,6 +91,7 @@ <h4 class="map-card-sidepanel-header" data-bind="click: hideSidePanel">
</div>
</div>
<!--/ko -->
{% endblock sidepanel %}
</div>
<!--/ko -->
<div class="map-card-container" data-bind="mapboxgl: {
Expand Down
2 changes: 1 addition & 1 deletion arches/install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@mapbox/geojson-extent": "0.3.2",
"@mapbox/mapbox-gl-draw": "1.0.8",
"@mapbox/mapbox-gl-draw": "1.1.2",
"@mapbox/mapbox-gl-geocoder": "^4.4.0",
"@turf/turf": "4.4.0",
"backbone": "1.3.3",
Expand Down
8 changes: 4 additions & 4 deletions arches/install/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
resolved "https://registry.yarnpkg.com/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz#ce56e539f83552b58d10d672ea4d6fc9adc7b234"
integrity sha1-zlblOfg1UrWNENZy6k1vya3HsjQ=

"@mapbox/mapbox-gl-draw@1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@mapbox/mapbox-gl-draw/-/mapbox-gl-draw-1.0.8.tgz#26115cea1fa07cfd6f1220a6231ea7c2dc13bbd2"
integrity sha1-JhFc6h+gfP1vEiCmIx6nwtwTu9I=
"@mapbox/mapbox-gl-draw@1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@mapbox/mapbox-gl-draw/-/mapbox-gl-draw-1.1.2.tgz#247b3f0727db34c2641ab718df5eebeee69a2585"
integrity sha512-DWtATUAnJaGZYoH/y2O+QTRybxrp5y3w3eV5FXHFNVcKsCAojKEMB8ALKUG2IsiCKqV/JCAguK9AlPWR7Bjafw==
dependencies:
"@mapbox/geojson-area" "^0.2.1"
"@mapbox/geojson-extent" "^0.3.2"
Expand Down

0 comments on commit f90c9a8

Please sign in to comment.