@@ -303,71 +303,97 @@ export class GeoJSONImageSource extends TiledImageSource {
303303 } else if ( type === 'LineString' ) {
304304
305305 ctx . beginPath ( ) ;
306-
307306 geometry . coordinates . forEach ( ( [ lon , lat ] , i ) => {
308307
309308 const [ px , py ] = projectPoint ( lon , lat ) ;
310- if ( i === 0 ) ctx . moveTo ( px , py ) ;
311- else ctx . lineTo ( px , py ) ;
309+ if ( i === 0 ) {
310+
311+ ctx . moveTo ( px , py ) ;
312+
313+ } else {
314+
315+ ctx . lineTo ( px , py ) ;
316+
317+ }
312318
313319 } ) ;
314320
315321 ctx . stroke ( ) ;
316322
317323 } else if ( type === 'MultiLineString' ) {
318324
325+ ctx . beginPath ( ) ;
319326 geometry . coordinates . forEach ( ( line ) => {
320327
321- ctx . beginPath ( ) ;
322328 line . forEach ( ( [ lon , lat ] , i ) => {
323329
324330 const [ px , py ] = projectPoint ( lon , lat ) ;
325- if ( i === 0 ) ctx . moveTo ( px , py ) ;
326- else ctx . lineTo ( px , py ) ;
331+ if ( i === 0 ) {
332+
333+ ctx . moveTo ( px , py ) ;
334+
335+ } else {
336+
337+ ctx . lineTo ( px , py ) ;
338+
339+ }
327340
328341 } ) ;
329- ctx . stroke ( ) ;
330342
331343 } ) ;
344+ ctx . stroke ( ) ;
332345
333346 } else if ( type === 'Polygon' ) {
334347
348+ ctx . beginPath ( ) ;
335349 geometry . coordinates . forEach ( ( ring , rIndex ) => {
336350
337- ctx . beginPath ( ) ;
338351 ring . forEach ( ( [ lon , lat ] , i ) => {
339352
340353 const [ px , py ] = projectPoint ( lon , lat ) ;
341- if ( i === 0 ) ctx . moveTo ( px , py ) ;
342- else ctx . lineTo ( px , py ) ;
354+ if ( i === 0 ) {
355+
356+ ctx . moveTo ( px , py ) ;
357+
358+ } else {
359+
360+ ctx . lineTo ( px , py ) ;
361+
362+ }
343363
344364 } ) ;
345365 ctx . closePath ( ) ;
346- // fill only outer ring
347- if ( rIndex === 0 ) ctx . fill ( ) ;
348- ctx . stroke ( ) ;
349366
350367 } ) ;
368+ ctx . fill ( 'evenodd' ) ;
369+ ctx . stroke ( ) ;
351370
352371 } else if ( type === 'MultiPolygon' ) {
353372
354373 geometry . coordinates . forEach ( ( polygon ) => {
355374
375+ ctx . beginPath ( ) ;
356376 polygon . forEach ( ( ring , rIndex ) => {
357377
358- ctx . beginPath ( ) ;
359378 ring . forEach ( ( [ lon , lat ] , i ) => {
360379
361380 const [ px , py ] = projectPoint ( lon , lat ) ;
362- if ( i === 0 ) ctx . moveTo ( px , py ) ;
363- else ctx . lineTo ( px , py ) ;
381+ if ( i === 0 ) {
382+
383+ ctx . moveTo ( px , py ) ;
384+
385+ } else {
386+
387+ ctx . lineTo ( px , py ) ;
388+
389+ }
364390
365391 } ) ;
366392 ctx . closePath ( ) ;
367- if ( rIndex === 0 ) ctx . fill ( ) ;
368- ctx . stroke ( ) ;
369393
370394 } ) ;
395+ ctx . fill ( 'evenodd' ) ;
396+ ctx . stroke ( ) ;
371397
372398 } ) ;
373399
0 commit comments