Skip to content

Commit 1b2e4a8

Browse files
committed
fixed bug that kept map from rerendering with style changes
1 parent 738daff commit 1b2e4a8

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

src/model/Msource.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export default {
1313
if (!source.url) throw new Error('no source.url');
1414
if (!source.type) throw new Error('no source.type');
1515

16+
if (source.url.indexOf('/localhost') !== -1){
17+
// check if user is also using localhost
18+
if (window.location.indexOf('/localhost') !== -1){
19+
return reject('not localhost');
20+
}
21+
}
22+
1623
//set key on source
1724
key = key || source.url;
1825

src/view/Vlayer/VlayerAdd.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export default class VlayerAdd extends React.Component {
153153
label:'Layer ID',
154154
value:this.state.id,
155155
placeholder:'Unique identifier for layer',
156+
inputNoAC:true,
156157
controlled:false
157158
}} key="id" handle={this.handle}/>
158159
</div>

src/view/Vmap/Vmapbox.jsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ export default class Vmapbox extends React.Component {
5757
</div>
5858
}
5959
componentWillReceiveProps (nextProps){
60-
if(!this.state.map) return;
60+
if(!this.map) return;
6161

6262
const {styleJS, handle, match} = nextProps;
6363

6464
//console.log('map match:',match);
6565

66-
//console.log('compare:',this.state.styleJS,styleJS);
66+
console.log('compare:',this.state.styleJS);
6767

68-
if (this.state.styleJS.equals(styleJS)) return;
68+
if (this.state.styleJS && this.state.styleJS.equals(styleJS)) return;
6969
this.setState({styleJS:styleJS});
7070

71-
//console.log('styleJs:',JSON.stringify(styleJS.toJS()));
71+
7272

7373
/*
7474
const metadata = nextProps.mapStyle.metadata || {}
@@ -79,7 +79,7 @@ export default class Vmapbox extends React.Component {
7979
Mstyle.errorsSet();
8080

8181
try {
82-
this.state.map.setStyle(styleJS.toJS(),{diff: true});
82+
this.map.setStyle(styleJS.toJS(),{diff: true});
8383
} catch(e){
8484
//console.error('map style error:',e);
8585
Mstyle.errorAdd(e);
@@ -89,7 +89,7 @@ export default class Vmapbox extends React.Component {
8989

9090
renderPopup (features){
9191

92-
console.log('render popup:',this);
92+
//console.log('render popup:',this);
9393

9494
const {handle} = this.props;
9595

@@ -197,15 +197,6 @@ export default class Vmapbox extends React.Component {
197197
});
198198

199199
this.map = map;
200-
201-
//this.setState({map:map});
202-
203-
204-
205-
//this.setState({map:map});
206-
207-
208-
209200
/*
210201
const map = new MapboxGl.Map({
211202
container: this.container,
@@ -248,7 +239,7 @@ export default class Vmapbox extends React.Component {
248239
map.on("data", e => {
249240
if(e.dataType !== 'tile') return
250241
this.props.onDataChange({
251-
map: this.state.map
242+
map: this.map
252243
})
253244
})
254245
*/

src/view/Vmap/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default class Vmap extends React.Component {
2121
render (){
2222
const {handle, match} = this.props;
2323

24+
console.log('render map!!!');
25+
2426
//get style
2527
switch (this.state.renderer){
2628
case 'mapbox':

src/view/Vsource/VsourceAdd.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ export default class VsourceAdd extends React.Component {
3333
submit:(e)=>{
3434
e.preventDefault();
3535

36+
37+
3638
Msource.add({
3739
url:this.state.url,
3840
type:this.state.type
3941
},this.state.name,this.state.makeLayers).then((source)=>{
4042
handle.route('source/'+encodeURIComponent(this.state.name));
4143
}).catch((e)=>{
44+
if (e === 'not localhost'){
45+
return this.setState({error:'the source you are adding is running locally and Fresco is not. You must run Fresco locally to be able to connect to this source.'});
46+
}
4247
console.log('catch error:',e);
4348
this.setState({error:''+e});
4449
});

0 commit comments

Comments
 (0)