22
33import React from 'react' ;
44import PropTypes from 'prop-types' ;
5- import homeSVG from '@assets/home-15 .svg' ;
5+ import addressSVG from '@assets/address-icon-48 .svg' ;
66import {
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