Skip to content

Instantly share code, notes, and snippets.

@DeaVenditama
Created September 9, 2020 07:27
Show Gist options
  • Save DeaVenditama/aaf0f75509376db3c3bbe06d215145ca to your computer and use it in GitHub Desktop.
Save DeaVenditama/aaf0f75509376db3c3bbe06d215145ca to your computer and use it in GitHub Desktop.
<?php namespace App\Controllers;
class Maps extends BaseController
{
public function index()
{
$model = new \App\Models\DataModel();
$fileName = base_url("maps/prov.geojson");
$file = file_get_contents($fileName);
$file = json_decode($file);
$features = $file->features;
foreach($features as $index=>$feature)
{
$kode_wilayah = $feature->properties->kode;
$data = $model->where('id_master_data',1)
->where('kode_wilayah', $kode_wilayah)
->first();
if($data)
{
$features[$index]->properties->nilai = $data->nilai;
}
}
$nilaiMax = $model->select('MAX(nilai) AS nilai')->where('id_master_data', 1)->first()->nilai;
return view('maps/index',[
'data' => $features,
'nilaiMax' => $nilaiMax,
]);
}
//--------------------------------------------------------------------
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment