@@ -44,6 +44,33 @@ const DEFAULT_SAMPLE = sampleButtons.length
4444 }
4545 : null ;
4646
47+ function createMarkerIcon ( color ) {
48+ const size = 22 ;
49+ const canvas = document . createElement ( 'canvas' ) ;
50+ canvas . width = size ;
51+ canvas . height = size ;
52+ const context = canvas . getContext ( '2d' ) ;
53+ if ( ! context ) {
54+ return canvas ;
55+ }
56+ const normalizedColor = typeof color === 'string' && color . trim ( ) ? color : '#60A5FA' ;
57+ context . clearRect ( 0 , 0 , size , size ) ;
58+ context . beginPath ( ) ;
59+ context . arc ( size / 2 , size / 2 , ( size / 2 ) - 2 , 0 , Math . PI * 2 ) ;
60+ context . closePath ( ) ;
61+ context . fillStyle = normalizedColor ;
62+ context . fill ( ) ;
63+ context . lineWidth = 2 ;
64+ context . strokeStyle = '#0f172a' ;
65+ context . stroke ( ) ;
66+ context . beginPath ( ) ;
67+ context . arc ( size / 2 , size / 2 , 3 , 0 , Math . PI * 2 ) ;
68+ context . closePath ( ) ;
69+ context . fillStyle = '#0f172a' ;
70+ context . fill ( ) ;
71+ return canvas ;
72+ }
73+
4774function showError ( message ) {
4875 errorBox . textContent = message ;
4976 errorBox . classList . remove ( 'hidden' ) ;
@@ -248,11 +275,13 @@ function handleMarkerSubmission(event) {
248275 popupTitle : title ,
249276 popupDesc : description
250277 } ;
251- if ( color ) {
252- markerOptions . color = color ;
253- }
254278 try {
255279 const marker = A . marker ( pendingMarkerPosition . ra , pendingMarkerPosition . dec , markerOptions ) ;
280+ marker . useMarkerDefaultIcon = false ;
281+ if ( typeof marker . setImage === 'function' ) {
282+ marker . setImage ( createMarkerIcon ( color ) ) ;
283+ }
284+ marker . color = color ;
256285 markerLayer . addSources ( [ marker ] ) ;
257286 placedMarkers . push ( marker ) ;
258287 updateRemoveMarkerState ( ) ;
0 commit comments