@@ -15,6 +15,7 @@ import { isColourValid } from '../osm/tags';
1515import { services } from '../services' ;
1616import { svgIcon } from '../svg/icon' ;
1717import { uiCmd } from './cmd' ;
18+ import { modeSelectNote } from '../modes' ;
1819
1920import {
2021 utilDisplayName ,
@@ -138,15 +139,15 @@ export function uiFeatureList(context) {
138139 }
139140
140141 // A location search takes priority over an ID search
141- var idMatch = ! locationMatch && q . match ( / (?: ^ | \W ) ( n o d e | w a y | r e l a t i o n | [ n w r ] ) \W { 0 , 2 } 0 * ( [ 1 - 9 ] \d * ) (?: \W | $ ) / i) ;
142+ var idMatch = ! locationMatch && q . match ( / (?: ^ | \W ) ( n o d e | w a y | r e l a t i o n | n o t e | [ n w r ] ) \W { 0 , 2 } 0 * ( [ 1 - 9 ] \d * ) (?: \W | $ ) / i) ;
142143
143144 if ( idMatch ) {
144- var elemType = idMatch [ 1 ] . charAt ( 0 ) ;
145+ var elemType = idMatch [ 1 ] === 'note' ? idMatch [ 1 ] : idMatch [ 1 ] . charAt ( 0 ) ;
145146 var elemId = idMatch [ 2 ] ;
146147 result . push ( {
147148 id : elemType + elemId ,
148- geometry : elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : 'relation' ,
149- type : elemType === 'n' ? t ( 'inspector.node' ) : elemType === 'w' ? t ( 'inspector.way' ) : t ( 'inspector.relation' ) ,
149+ geometry : elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : elemType === 'note' ? 'note' : 'relation' ,
150+ type : elemType === 'n' ? t ( 'inspector.node' ) : elemType === 'w' ? t ( 'inspector.way' ) : elemType === 'note' ? t ( 'note.note' ) : t ( 'inspector.relation' ) ,
150151 name : elemId
151152 } ) ;
152153 }
@@ -232,6 +233,12 @@ export function uiFeatureList(context) {
232233 type : t ( 'inspector.relation' ) ,
233234 name : q
234235 } ) ;
236+ result . push ( {
237+ id : 'note' + q ,
238+ geometry : 'note' ,
239+ type : t ( 'note.note' ) ,
240+ name : q
241+ } ) ;
235242 }
236243
237244 return result ;
@@ -353,6 +360,26 @@ export function uiFeatureList(context) {
353360 context . enter ( modeSelect ( context , [ d . entity . id ] ) ) ;
354361 context . map ( ) . zoomToEase ( d . entity ) ;
355362
363+ } else if ( d . geometry === 'note' ) {
364+ // note
365+ // get number part 'note12345'
366+ const noteId = d . id . replace ( / \D / g, '' ) ;
367+
368+ // load note
369+ context . loadNote ( noteId , ( err , result ) => {
370+ if ( err ) return ;
371+ const entity = result . data . find ( e => e . id === noteId ) ;
372+ if ( entity ) {
373+ // zoom to, used note loc
374+ const note = services . osm . getNote ( noteId ) ;
375+ context . map ( ) . centerZoom ( note . loc , 15 ) ;
376+ // open note layer
377+ const noteLayer = context . layers ( ) . layer ( 'notes' ) ;
378+ noteLayer . enabled ( true ) ;
379+ // select the note
380+ context . enter ( modeSelectNote ( context , noteId ) ) ;
381+ }
382+ } ) ;
356383 } else {
357384 // download, zoom to, and select the entity with the given ID
358385 context . zoomToEntity ( d . id ) ;
0 commit comments