Skip to content

Commit 738daff

Browse files
committed
added debug lines, upgraded mapbox-gl to v0.46.0, and added feature inspecting - closes #21
1 parent 2923fda commit 738daff

File tree

21 files changed

+685
-335
lines changed

21 files changed

+685
-335
lines changed

package-lock.json

Lines changed: 184 additions & 298 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"js-file-download": "^0.4.1",
2828
"jshint": "^2.9.5",
2929
"jsonlint-lines-primitives": "^1.6.0",
30-
"mapbox-gl": "^0.44.2",
30+
"mapbox-gl": "^0.46.0",
3131
"mapbox-gl-inspect": "^1.3.1",
3232
"react-beautiful-dnd": "^7.1.3",
3333
"react-color": "^2.14.1",

src/App.css

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ label .badge{position:relative;top:2px;}
3131
.btn.btn-primary{background-color:#00ACC1;border-color:#00A7B6;}
3232
.btn.btn-primary:hover{background-color:#00A7B6;border-color:#0094A0;}
3333
.btn.btn-primary:active{background-color:#0094A0;border-color:#0094A0;}
34-
34+
.btn.btn-gray{background-color:#37474F;color:#FFFFFF;}
35+
.btn.btn-gray:hover{background-color:#273237;}
3536
.btn.btn-light:focus{box-shadow:0 0 0 0.2rem rgba(0,123,255,.25);}
3637

3738
/* Code mirror */
@@ -78,9 +79,10 @@ label .badge{position:relative;top:2px;}
7879
.font-lg{font-size:0.9rem;}
7980

8081
.form-group label{font-size:0.8em;}
81-
.form-control{font-size:0.85em;}
82-
.form-control-sm{font-size:0.875rem;}
82+
.form-control{font-size:0.75rem;}
83+
.form-control-sm{font-size:0.65rem;}
8384
.form-control .btn{line-height:1.2;}
85+
.form-control .btn-right{float:right;position:relative;top:-4px;right:-10px;}
8486

8587
.func-border{border:1px solid #546D79;}
8688
.func-add{border:1px dashed #EEEEEE;padding:0.2rem;font-size:0.7em;
@@ -99,7 +101,12 @@ label .badge{position:relative;top:2px;}
99101

100102
.inline-block{display:inline-block;}
101103

102-
.form-control .btn-right{float:right;position:relative;top:-3px;right:-9px;}
104+
.inspector-back{color:#AEAEAE;position:absolute;left:0;top:0;border:0;
105+
border-radius:0 3px 0 0;cursor:pointer;background-color:transparent;}
106+
.inspector-back:hover{color:#747474;background-color: rgba(0, 0, 0, 0.05);}
107+
.inspector-overflow{padding-top:6px;max-width:200px;max-height:200px;overflow:auto;}
108+
109+
103110

104111
.layer-nav-link{border-bottom:3px solid transparent;cursor:pointer;}
105112
.layer-nav-link.active{border-bottom:3px solid #273237;}
@@ -142,6 +149,10 @@ label .badge{position:relative;top:2px;}
142149
.map-inspect-list a{color:inherit;}
143150
.map-inspect-list .list-left{top:-1px;left:0;}
144151

152+
.mapboxgl-ctrl-icon.active{background-color:#00ACC1;color:#FFF;}
153+
.mapboxgl-ctrl-icon.active:hover{background-color:#0197A7;color:#FFF;}
154+
.mapboxgl-ctrl-icon i{position:relative;top:-1px;}
155+
145156
.mapboxgl-popup-close-button{color:#AEAEAE;}
146157
.mapboxgl-popup-close-button:hover{color:#747474;}
147158

@@ -173,6 +184,8 @@ label .badge{position:relative;top:2px;}
173184
.o-scroll{overflow:scroll;}
174185
.o-y-scroll{overflow-y:auto;}
175186

187+
.panel-float{position:fixed;z-index:1000;}
188+
176189
.panel-min-height{min-height:300px;}
177190
.panel-z-index{z-index:3;}
178191

src/model/Mlayer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ export default {
198198
return Store.getState().style.getIn(['rec','layers',ind])
199199
},
200200

201+
getType:function(layerId){
202+
const layer = this.get(layerId);
203+
if (!layer || !layer.has) return;
204+
if (layer.has('type')) return layer.get('type');
205+
if (layer.has('ref')){
206+
const refLayer = this.get(layer.get('ref'));
207+
if (refLayer.has('type')) return refLayer.get('type');
208+
}
209+
// no type found
210+
},
211+
201212
getInd:function(layerId){
202213
return Store.getState().style.getIn(['rec','layers']).findIndex((layer)=>{
203214
//console.log('layer:',layer)

src/model/Mpanel.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Store from '../Store';
2+
3+
export default {
4+
add:function(panel){
5+
return new Promise((resolve,reject)=>{
6+
if (!panel.float) return reject('no float defined');
7+
if (!panel.id) return reject('no panel id');
8+
9+
Store.dispatch({
10+
type:'PANEL_ADD',
11+
payload:panel
12+
});
13+
14+
return resolve(panel);
15+
});
16+
},
17+
18+
getAll:function(){
19+
return Store.getState().panel.get('recs');
20+
},
21+
get:function(id){
22+
const panels = this.getAll();
23+
let res;
24+
panels.map((panel)=>{
25+
if (panel.get('id') === id) res = panel;
26+
});
27+
return res;
28+
}
29+
};

src/page/Pstyle.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import Valert from '../view/Valert';
88
import Vmap from '../view/Vmap';
99
import Vstyle from '../view/Vstyle';
1010

11+
import Vpanel from '../view/Vpanel';
12+
import Mpanel from '../model/Mpanel';
13+
1114
const mapStoreToProps = (store)=>{
1215
return {
1316
style:store.style,
@@ -35,7 +38,7 @@ class Pstyle extends React.Component {
3538

3639
Mstyle.load(this.id);
3740
Mstyle.errorsSet();
38-
41+
3942
this.handle = {
4043
route:(path)=>{
4144
this.props.history.push('/style/'+this.id+'/'+path);

src/reducer/Rpanel.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Map, List, fromJS} from 'immutable';
2+
3+
const iState = Map({
4+
recs:List([])
5+
});
6+
7+
export default function(state = iState, action){
8+
switch (action.type){
9+
case 'PANEL_ADD':{
10+
const rec = fromJS(action.payload);
11+
const recs = state.get('recs').push(rec);
12+
return state.set('recs',recs);
13+
}
14+
default:
15+
return state;
16+
}
17+
}

src/reducer/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import {combineReducers} from 'redux';
22
import Rconfig from './Rconfig';
3+
import Rpanel from './Rpanel';
34
import Rstyle from './Rstyle';
45
import RstyleError from './RstyleError';
56
import Rstyles from './Rstyles';
67

78
export default combineReducers({
9+
panel:Rpanel,
810
styles:Rstyles,
911
style:Rstyle,
1012
styleError:RstyleError,

src/utility/LayerIcon.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import layerConfig from '../config/layer';
22
import {List, Map} from 'immutable';
3+
import Mlayer from '../model/Mlayer';
34

45
const CSS_COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","Darkorange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"];
56

@@ -51,7 +52,7 @@ export default {
5152
*/
5253
},
5354
getIcon:function(layer){
54-
const type = layer.get('type'),
55+
const type = Mlayer.getType(layer.get('id')),
5556
config = layerConfig.types[type];
5657
if (!config) return null;
5758
return config.icon;

src/view/Vfeature/index.jsx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
export default class Vfeature extends React.Component {
5+
6+
static propTypes = {
7+
features: PropTypes.array,
8+
handle: PropTypes.object
9+
}
10+
11+
constructor(props) {
12+
super(props);
13+
this.state = {};
14+
}
15+
16+
render (){
17+
const {features, handle} = this.props;
18+
19+
// get property values
20+
21+
let cols = ['id'];
22+
features.map((feature)=>{
23+
if (!feature.properties) return;
24+
Object.keys(feature.properties).map((i)=>{
25+
if (cols.indexOf(i) === -1) cols.push(i);
26+
});
27+
});
28+
29+
let ids = [];
30+
let uniqueFeatures = features.filter((feature)=>{
31+
// check if feature is already in
32+
if (ids.indexOf(feature.id) === -1){
33+
ids.push(feature.id);
34+
return true;
35+
}
36+
return false;
37+
});
38+
39+
40+
return <table className="table font-sm table-sm">
41+
<thead>
42+
<tr>
43+
{cols.map((col)=>{
44+
return <th key={col}>{col}</th>
45+
})}
46+
</tr>
47+
</thead>
48+
<tbody>
49+
{uniqueFeatures.map((feature)=>{
50+
return <tr key={feature.id}>
51+
{cols.map((col)=>{
52+
return <td key={col}>
53+
{feature.properties[col] || feature[col]}
54+
</td>
55+
})}
56+
</tr>
57+
})}
58+
</tbody>
59+
60+
</table>
61+
62+
/*
63+
64+
{features.map((feature)=>{
65+
66+
console.log('feature:',feature);
67+
68+
return <li key={feature.id} onClick={()=>{this.handle.featureClick(feature);}}><a href="javascript://">
69+
{Object.keys(feature.properties).map((i)=>{
70+
return i+': '+feature.properties[i];
71+
})}
72+
</a></li>
73+
})}
74+
75+
*/
76+
}
77+
};

0 commit comments

Comments
 (0)