Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: GeoJSON で marker-symbol を指定してもアイコンが表示されない #320

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ <h2>GeoJSON with SimpleStyle</h2>
"title": "集合場所",
"description": "ここが集合場所です。13時までに集合してください。",
"marker-color": "#0096ff",
"marker-size": "medium",
"marker-symbol": ""
"marker-size": "medium"
},
"geometry": {
"type": "Point",
Expand All @@ -162,9 +161,10 @@ <h2>GeoJSON with SimpleStyle</h2>
"type": "Feature",
"properties": {
"title": "売店",
"description": "ここは売店です。お好きなものを買ってください。",
"marker-color": "#ff9300",
"marker-size": "medium",
"marker-symbol": "bus"
"marker-symbol": "star-stroked"
},
"geometry": {
"type": "Point",
Expand All @@ -179,8 +179,7 @@ <h2>GeoJSON with SimpleStyle</h2>
"properties": {
"title": "噴水",
"marker-color": "#ff2600",
"marker-size": "large",
"marker-symbol": ""
"marker-size": "large"
},
"geometry": {
"type": "Point",
Expand Down
9 changes: 3 additions & 6 deletions src/lib/simplestyle-vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SimpleStyleVector {
type: 'circle',
source: this.sourceName,
'source-layer': 'g-simplestyle-v1',
filter: ['==', '$type', 'Point'],
filter: ['all', ['==', '$type', 'Point'], ['!has', 'marker-symbol']],
paint: {
'circle-radius': [
'case',
Expand Down Expand Up @@ -180,11 +180,7 @@ class SimpleStyleVector {
'text-halo-width': 1,
},
layout: {
'icon-image': [
'case',
['==', 'large', ['get', 'marker-size']], ['image', ['concat', ['get', 'marker-symbol'], '-15']],
['image', ['concat', ['get', 'marker-symbol'], '-11']],
],
'icon-image': ['get', 'marker-symbol'],
'text-field': ['get', 'title'],
'text-font': ['Noto Sans Regular'],
'text-size': 12,
Expand All @@ -201,6 +197,7 @@ class SimpleStyleVector {
});

this.setPopup(map, 'vt-circle-simple-style-points');
this.setPopup(map, 'vt-geolonia-simple-style-points');
}

async setPopup(map, source) {
Expand Down
9 changes: 3 additions & 6 deletions src/lib/simplestyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class SimpleStyle {
id: `${this.options.id}-circle-points`,
type: 'circle',
source: `${this.options.id}-points`,
filter: ['!', ['has', 'point_count']],
filter: ['all', ['!has', 'point_count'], ['!has', 'marker-symbol']],
paint: {
'circle-radius': [
'case',
Expand All @@ -223,11 +223,7 @@ class SimpleStyle {
'text-halo-width': 1,
},
layout: {
'icon-image': [
'case',
['==', 'large', ['get', 'marker-size']], ['image', ['concat', ['get', 'marker-symbol'], '-15']],
['image', ['concat', ['get', 'marker-symbol'], '-11']],
],
'icon-image': ['get', 'marker-symbol'],
'text-field': ['get', 'title'],
'text-font': ['Noto Sans Regular'],
'text-size': 12,
Expand All @@ -244,6 +240,7 @@ class SimpleStyle {
});

this.setPopup(this.map, `${this.options.id}-circle-points`);
this.setPopup(this.map, `${this.options.id}-symbol-points`);
}

async setPopup(map, source) {
Expand Down