Skip to content

Commit 40ff691

Browse files
authored
Merge pull request #1959 from DorianDeptuch/update-the-home-icon-with-a-pin-icon-1905
Update the home icon with a pin icon 1905
2 parents c8ccbb7 + e34ba93 commit 40ff691

2 files changed

Lines changed: 56 additions & 17 deletions

File tree

assets/address-icon-48.svg

Lines changed: 18 additions & 0 deletions
Loading

components/Map/layers/AddressLayer.js

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React from 'react';
44
import PropTypes from 'prop-types';
5-
import homeSVG from '@assets/home-15.svg';
5+
import addressSVG from '@assets/address-icon-48.svg';
66
import {
77
emptyGeo,
88
makeGeoCircle,
@@ -69,8 +69,8 @@ class AddressLayer extends React.Component {
6969

7070
addImages = () => {
7171
let img = new Image(30, 30);
72-
img.onload = () => this.map.addImage('home-icon', img);
73-
img.src = homeSVG;
72+
img.onload = () => this.map.addImage('address-icon', img);
73+
img.src = addressSVG;
7474
}
7575

7676
addSources = () => {
@@ -81,14 +81,33 @@ class AddressLayer extends React.Component {
8181
};
8282

8383
addLayers = () => {
84-
this.map.addLayer({
85-
id: 'point',
86-
type: 'symbol',
87-
source: 'point',
88-
layout: {
89-
'icon-image': 'home-icon',
90-
},
91-
})
84+
// Default layer
85+
if (!this.map.getLayer('point')) {
86+
this.map.addLayer({
87+
id: 'point',
88+
type: 'symbol',
89+
source: 'point',
90+
layout: {
91+
'icon-image': 'address-icon',
92+
'icon-size': 1
93+
}
94+
});
95+
}
96+
97+
// Hover layer
98+
if (!this.map.getLayer('point-hover')) {
99+
this.map.addLayer({
100+
id: 'point-hover',
101+
type: 'circle',
102+
source: 'point',
103+
paint: {
104+
'circle-radius': 4,
105+
'circle-color': '#1D6996',
106+
'circle-opacity': 0,
107+
'circle-translate': [0, -3.5]
108+
}
109+
});
110+
}
92111
};
93112

94113
addListeners = () => {
@@ -128,13 +147,15 @@ class AddressLayer extends React.Component {
128147
// this.map.once('touchend', onUp);
129148
// });
130149

131-
// this.map.on('mouseenter', 'shed-fill', e => {
132-
// this.canvas.style.cursor = 'move';
133-
// });
150+
this.map.on('mouseenter', 'point', () => {
151+
this.map.setPaintProperty('point-hover', 'circle-opacity', 1);
152+
this.canvas.style.cursor = 'pointer';
153+
});
134154

135-
// this.map.on('mouseleave', 'shed-fill', e => {
136-
// this.canvas.style.cursor = '';
137-
// });
155+
this.map.on('mouseleave', 'point', () => {
156+
this.map.setPaintProperty('point-hover', 'circle-opacity', 0);
157+
this.canvas.style.cursor = '';
158+
});
138159
}
139160

140161
// setVisibility = visible => {

0 commit comments

Comments
 (0)