Skip to content

Commit

Permalink
issue #356 - fix bad source reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yermo committed Apr 29, 2020
1 parent 6714df2 commit c505088
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions demo-angular/src/app/components/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ export class MapComponent implements OnInit, OnDestroy {

console.log( "MapComponent:onMapReady(): after declareReady()" );

this.addTestCircle();

} // end of onMapReady()

// --------------------------------------
Expand Down
24 changes: 14 additions & 10 deletions src/mapbox.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2959,15 +2959,21 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
return new Promise((resolve, reject) => {
try {
const { url, type } = options;
const theMap = nativeMap;
let theMap = nativeMap;
let source;

if (!theMap) {
reject("No map has been loaded");
return;
if ( ! theMap ) {

if ( !this._mapboxMapInstance ) {
reject("No map has been loaded");
return;
}

theMap = this._mapboxMapInstance;

}

if ( theMap.mapboxMap.getSource(id) ) {
if ( theMap.getStyle().getSource(id) ) {
reject("Source exists: " + id);
return;
}
Expand All @@ -2990,14 +2996,12 @@ export class Mapbox extends MapboxCommon implements MapboxApi {

// com.mapbox.mapboxsdk.maps.Style

let geoJsonSource = new com.mapbox.mapboxsdk.style.sources.GeoJsonSource(
source = new com.mapbox.mapboxsdk.style.sources.GeoJsonSource(
id,
feature
);

this._mapboxMapInstance.getStyle().addSource( geoJsonSource );

this.gcFix( 'com.mapbox.mapboxsdk.style.sources.GeoJsonSource', geoJsonSource );
this.gcFix( 'com.mapbox.mapboxsdk.style.sources.GeoJsonSource', source );

// To support handling click events on lines and circles, we keep the underlying
// feature.
Expand Down Expand Up @@ -3039,7 +3043,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
return;
}

theMap.mapboxMap.addSource(source);
theMap.getStyle().addSource( source );
resolve();
} catch (ex) {
console.log("Error in mapbox.addSource: " + ex);
Expand Down

1 comment on commit c505088

@mircobabini
Copy link

Choose a reason for hiding this comment

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

This one can be immediately merged into master in order to fix the 5.0.1 issue: no line can be drawn on the map.

Please sign in to comment.