Skip to content

Commit

Permalink
Merge pull request #4 from watergis/fix/bug
Browse files Browse the repository at this point in the history
fixed bug
  • Loading branch information
Jin Igarashi authored Jan 18, 2021
2 parents 3539fe3 + 6674420 commit c50e312
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "../styles.css"
uri:"https://wasac.github.io/mapbox-stylefiles/unvt/style.json"
}
];
const defaultStyle = styles[1];
const defaultStyle = styles[0];

const map = new mapboxgl.Map({
container: 'map',
Expand Down
9 changes: 6 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ export class MapboxStyleSwitcherControl implements IControl
srcElement.classList.add("active");
});
if (style.title === this.defaultStyleFromUrl){
styleElement.classList.add("active");
this.map!.setStyle(style.uri);
const elms = this.mapStyleContainer!.getElementsByClassName("active");
if (elms.length === 0){
styleElement.classList.add("active");
this.map!.setStyle(style.uri);
}
}
if (style.title === this.defaultStyle)
if (!this.defaultStyleFromUrl && style.title === this.defaultStyle)
{
const elms = this.mapStyleContainer!.getElementsByClassName("active");
if (elms.length === 0){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@watergis/mapbox-gl-style-switcher",
"version": "1.0.10",
"version": "1.0.11",
"description": "Mapbox GL JS Style Switcher",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit c50e312

Please sign in to comment.