Skip to content

Add coordinates of mapbox view as a derived property in plotly_relayo… - #4413

Merged
jonmmease merged 9 commits into
masterfrom
mapbox_view
Dec 9, 2019
Merged

Add coordinates of mapbox view as a derived property in plotly_relayo…#4413
jonmmease merged 9 commits into
masterfrom
mapbox_view

Conversation

@jonmmease

Copy link
Copy Markdown
Contributor

Closes#4399, following @alexcjohnson 's suggestion from #4399 (comment).

@archmojarchmoj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonmmease thanks very much for the PR!
Please find my questions below:

Comment threadtest/jasmine/tests/mapbox_test.js Outdated
Comment threadtest/jasmine/tests/mapbox_test.js Outdated
@etpinardetpinard added this to the v1.52.0 milestone Dec 6, 2019
Comment threadsrc/plots/mapbox/mapbox.js Outdated
Comment threadsrc/plots/mapbox/mapbox.js Outdated
Comment threadsrc/plots/mapbox/mapbox.js Outdated
@jonmmease

Copy link
Copy Markdown
ContributorAuthor

Thanks very much for the review @archmoj and @etpinard. I believe I made the requested updates. Anything else?

@jonmmease

Copy link
Copy Markdown
ContributorAuthor

Oh, I just noticed that these changes were resulting in a "unrecognized GUI edit" warning on the _derived property when resetting the plot with the modebar button. I added a check to prevent this in cf2c4fc, but let me know if you see a more elegent way to do this.

@jonmmeasejonmmease mentioned this pull request Dec 8, 2019
@etpinard

Copy link
Copy Markdown
Contributor

Oh, I just noticed that these changes were resulting in a "unrecognized GUI edit" warning on the _derived property when resetting the plot with the modebar button

Ideally, 'mapbox._derived.coordinates[i][j] keys should never slip into the fullLayout._preGUI object. So yeah we could probably do better than your attempt in cf2c4fc.

Looks like you were successful at that on user pan and scroll-zoom: fullLayout._preGUI only contains mapbox center, zoom, bearing and pitch keys after those.

The logic for the modebar "reset" button is here:

for(vari=0;i<subplotIds.length;i++){
varid=subplotIds[i];
varsubplotObj=fullLayout[id]._subplot;
varviewInitial=subplotObj.viewInitial;
varviewKeys=Object.keys(viewInitial);
for(varj=0;j<viewKeys.length;j++){
varkey=viewKeys[j];
aObj[id+'.'+key]=viewInitial[key];
}
}

it relies on viewInitial - which does get filled with _derived in your new updateDerived mapbox subplot instance method. So I see two ways of fixing the problem,

  • not stash _dervied values key-values into viewInitial (right? do we really need to stash them?)
  • have the "reset" modebar button handler skip over _ keys in viewInitial

@jonmmease

Copy link
Copy Markdown
ContributorAuthor

Thank for taking a look @etpinard, I went ahead and removed _derived from viewInitial since this wasn't needed after all.

@etpinard

Copy link
Copy Markdown
Contributor

💃 thanks @jonmmease !!

@jonmmease

Copy link
Copy Markdown
ContributorAuthor

Thanks! merging

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

featuresomething new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: provide mapbox viewport coordinates in relayout data

3 participants

@jonmmease@etpinard@archmoj