Skip to content

Commit

Permalink
🔧 Fix Geojson cannot load #1
Browse files Browse the repository at this point in the history
Refactor code
Remove umami script
  • Loading branch information
iqfareez committed Nov 21, 2024
1 parent 7bfbe00 commit 5096ac6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 49 deletions.
6 changes: 1 addition & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>

<!-- umami analytics -->
<!-- See analytics data on: https://umami.iqfareez.com/share/EkKhREDfqLNqTPX9/Peta%20Waktu%20Solat -->
<script async src="https://umami-iqfareez.netlify.app/script.js" data-website-id="2910cac4-b314-435d-93a5-5fcce28fd62f"></script>
</head>

<body>
Expand All @@ -52,7 +48,7 @@ <h1 class="text-2xl font-bold">Peta Zon Waktu Solat</h1>
<p class="text-slate-600 dark:text-slate-400">Aplikasi ini supaya dapat menggambarkan zon waktu solat di
Malaysia</p>
<br />
<p>Untuk mengetahui lebih lanjut tentang bagaimana data ini dikumpulkan, sila pergi ke <a
<p>Untuk mengetahui lebih lanjut tentang bagaimana data ini dikumpulkan, sila pergi ke Github Repository <a
href="https://github.com/mptwaktusolat/jakim.geojson?tab=readme-ov-file#methodology">jakim.geojson</a>
</p>
<br />
Expand Down
61 changes: 17 additions & 44 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,22 @@ map.setMaxBounds(bounds);

function polystyle(feature) {
let color = 'blue';
switch (feature.properties.state) {
case 'SGR':
color = 'red';
break;
case 'KDH':
color = 'green';
break;
case 'PLS':
color = 'yellow';
break;
case 'TRG':
color = 'purple';
break;
case 'KTN':
color = 'orange';
break;
case 'PHG':
color = 'brown';
break;
case 'PRK':
color = '#60E550';
break;
case 'SBH':
color = '#F67575';
break;
case 'SWK':
color = '#FFA34D';
break;
case 'MLK':
color = '#219C90';
break;
case 'PNG':
color = '#D3504A';
break;
case 'JHR':
color = '#22B2DA';
break;
case 'NSN':
color = '#6C4AB6';
break;
default:
break;
}
const stateColors = {
SGR: 'red',
KDH: 'green',
PLS: 'yellow',
TRG: 'purple',
KTN: 'orange',
PHG: 'brown',
PRK: '#60E550',
SBH: '#F67575',
SWK: '#FFA34D',
MLK: '#219C90',
PNG: '#D3504A',
JHR: '#22B2DA',
NSN: '#6C4AB6',
};
color = stateColors[feature.properties.state] || 'blue';
return {
fillColor: color,
weight: 2,
Expand Down Expand Up @@ -105,7 +78,7 @@ function onFeatureClick(e) {

let geoJSONLayer;
// Fetch GeoJSON data
fetch('https://corsproxyuia.up.railway.app/https://github.com/mptwaktusolat/jakim.geojson/raw/master/malaysia.district-jakim.geojson')
fetch('https://raw.githubusercontent.com/mptwaktusolat/jakim.geojson/master/malaysia.district-jakim.geojson')
.then(response => response.json())
.then(data => {
const features = data.features;
Expand Down

0 comments on commit 5096ac6

Please sign in to comment.