Skip to content

Commit

Permalink
Merge pull request mapbox#327 from mapbox/fix-selection
Browse files Browse the repository at this point in the history
correctly set cold data, closes mapbox#323
  • Loading branch information
samanpwbb committed Jun 7, 2016
2 parents 3334153 + 6b99fab commit e88407b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/render.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function render() {
var isStillAlive = this.ctx.map && this.ctx.map.getSource('mapbox-gl-draw-hot') !== undefined;
if (isStillAlive) { // checks to make sure we still have a map
var mapExists = this.ctx.map && this.ctx.map.getSource('mapbox-gl-draw-hot') !== undefined;
if (mapExists) {
var mode = this.ctx.events.currentModeName();
this.ctx.ui.setClass({
mode: mode
Expand All @@ -26,6 +26,8 @@ module.exports = function render() {
return newHotIds.indexOf(id) === -1;
});

var coldChanged = lastColdCount !== this.sources.cold.length || newColdIds.length > 0;

newHotIds.concat(newColdIds).map(function prepForViewUpdates(id) {
if (newHotIds.indexOf(id) > -1) {
return {source: 'hot', 'id': id};
Expand All @@ -43,7 +45,7 @@ module.exports = function render() {
}.bind(this));
}.bind(this));

if (lastColdCount !== this.sources.cold.length) {
if (coldChanged) {
this.ctx.map.getSource('mapbox-gl-draw-cold').setData({
type: 'FeatureCollection',
features: this.sources.cold
Expand Down

0 comments on commit e88407b

Please sign in to comment.