Skip to content

Commit

Permalink
conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Mar 4, 2019
2 parents 99210e4 + 2ad6823 commit f3b840c
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions inst/htmlwidgets/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
tooltipdiv.setAttribute("id", "mapdecktooltip"+el.id);
mapDiv.appendChild(tooltipdiv);

/*
// INITIAL VIEW
window[el.id + 'INITIAL_VIEW_STATE'] = {
longitude: x.location[0],
Expand All @@ -48,24 +49,30 @@
pitch: x.pitch,
bearing: x.bearing
};
*/

mapboxgl.accessToken = x.access_token;

var map = new mapboxgl.Map({
container: el.id,
style: x.style,
zoom: x.zoom,
center: [x.location[0], x.location[1]],
pitch: x.pitch,
var map = new mapboxgl.Map({
container: el.id,
style: x.style,
zoom: x.zoom,
center: [x.location[0], x.location[1]],
pitch: x.pitch,
bearing: x.bearing
});
});

// TODO make this optional
//map.addControl(new mapboxgl.NavigationControl());
//map.addControl(new mapboxgl.NavigationControl());

var checkExists = setInterval(function () {
map.on('styledata', function() {
clearInterval(checkExists);
window[el.id + 'map'] = map;
md_initialise_mapbox(el, x);
});
}, 100);

window[el.id + 'map'] = map;
md_initialise_mapbox(el, x);
},

resize: function(width, height) {
Expand All @@ -77,27 +84,39 @@
}
});

function add_mapbox_layer( map_id, layer_json ) {
var map = window[ map_id + 'map'];
var js = JSON.parse( layer_json );
//map.on('styledata', function() {
map.addLayer( js );
//});
}

function add_mapbox_source( map_id, id, source_json ) {
var map = window[ map_id + 'map'];
var js = JSON.parse( source_json );
map.on('styledata', function() {
var mapLayer = map.getLayer( id );
if( typeof mapLayer === 'undefined' ) {

console.log( js );

//map.on('styledata', function() {

//var mapLayer = map.getLayer( id );
//if( typeof mapLayer === undefined ) {
map.addSource( id, js );
}
});
//}
//});
}

/*
function add_mapbox_layer( map_id, layer_json ) {
var map = window[ map_id + 'map'];
var js = JSON.parse( layer_json );
map.on('styledata', function() {
map.addLayer( js );
console.log( map.getLayer( 'contours' ) );
});

}

*/

if (HTMLWidgets.shinyMode) {

Expand Down

0 comments on commit f3b840c

Please sign in to comment.