Skip to content

Commit

Permalink
Merge pull request #260 from CityOfDetroit/feature.259
Browse files Browse the repository at this point in the history
Feature.259
  • Loading branch information
jedgar1mx authored Aug 21, 2024
2 parents 84b2df1 + 92e4ad9 commit 03062d7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/assets/js/main.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions src/components/organisms/Map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ export default class Map extends HTMLElement {

if (newValue === 'init') {
this.map.addControl(new maplibregl.NavigationControl());
this.map.on('load', () => {
const mapImgs = JSON.parse(this.getAttribute('data-map-images'));
if (mapImgs) {
// Load an image from an external URL.
mapImgs.forEach((img) => {
this.map.loadImage(img.source, (error, image) => {
if (error) throw error;
// Add the image to the map style.
if (!this.map.hasImage(img.id)) {
this.map.addImage(img.id, image);
}
});
});
}
});
this.map.on('style.load', () => {
this.map.resize();

Expand Down Expand Up @@ -368,6 +383,25 @@ export default class Map extends HTMLElement {
});
return tmpLayer;

case 'image':
tmpLayer.type = 'symbol';
tmpLayer.source = layer.source;
layer.minZoom ? (tmpLayer.minzoom = layer.minZoom) : 0;
layer.maxZoom ? (tmpLayer.maxzoom = layer.maxZoom) : 0;
layer.filter ? (tmpLayer.filter = layer.filter) : 0;
layer.active
? (tmpLayer.layout = {
visibility: 'visible',
'icon-image': layer.img,
'icon-size': layer.imgSize,
})
: (tmpLayer.layout = {
visibility: 'none',
'icon-image': layer.img,
'icon-size': layer.imgSize,
});
return tmpLayer;

case 'circle':
tmpLayer.type = layer.type;
tmpLayer.source = layer.source;
Expand Down
Binary file added src/stories/assets/building.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/stories/assets/hook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions src/stories/map.stories.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03062d7

Please sign in to comment.