TIF_E41201448/application/views/dist/v_peta.php

223 lines
6.9 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
$this->load->view('dist/_partials/header');
?>
<!-- Main Content -->
<div class="main-content">
<section class="section">
<div class="section-header">
<?php
$tah=$_GET['tahun'];
?>
<h1>Peta Rawan Pencurian Ternak Kabupaten Lumajang Tahun <?php echo $tah;?></h1>
<div class="section-header-breadcrumb">
<div class="breadcrumb-item active"><a href="#">Dashboard</a></div>
<div class="breadcrumb-item">peta</div>
</div>
</div>
<div class="section-body">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="tile">
<div class="tile-body">
<div id="mapid" style="height:600px;"></div>
</div>
</div>
<script>
var map = L.map("mapid").setView([-8.137977327799765, 113.13331709073779], 11);
var basemap = L.tileLayer(
"https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
{
maxZoom: 20,
subdomains: ["mt0", "mt1", "mt2", "mt3"],
attribution: 'Google | <a href="#">unsorry@2020</a>',
}
);
basemap.addTo(map);
// control that shows state info on hover
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info1');
this.update();
return this._div;
};
info.update = function (props) {
};
info.addTo(map);
function getColor(d) {
return d == 3 ? '#ff510d' :
d == 2 ? '#fcff0d' :
d == 1 ? '#0dffa8' :
'#0dffa8';
}
function style(feature) {
return {
weight: -1,
opacity: 0.5,
color: 'black',
fillOpacity: 0.3,
fillColor: getColor(feature)
};
}
function highlightFeature(e) {
var layer = e.target;
var placeId = layer.feature.properties.GID_4;
layer.setStyle({
weight: 5,
opacity: 1,
color: 'black',
dashArray: '',
fillOpacity: 1
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
}
var jsonData;
function resetHighlight(e) {
// jsonData.resetStyle(e.target);
var layer = e.target;
layer.setStyle({
weight: -1,
opacity: 0.5,
color: 'black',
fillOpacity: 0.4,
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
info.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
});
var content = layer.feature.properties.name.toString();
layer.bindTooltip(content, {
direction: "center",
permanent: true,
className: "styleLabelkecamatan",
});
}
<?php
$th = $_GET['tahun'];
foreach ($rendah->result_array() as $r) {
$_r = $r['alternatif_id'];
$data_kamp = $this->db->query("SELECT alternatif_file FROM alternatif WHERE alternatif_id = '$_r'")->row();
$data_krit = $this->db->query("SELECT * FROM kriteria WHERE alternatif_id = '$_r' and tahun='$th'")->row();
$nama = $this->db->query("SELECT alternatif_nama FROM alternatif WHERE alternatif_id = '$_r'")->row();?>
var jsonData = new L.GeoJSON.AJAX([
"<?php echo base_url() ?>assets/geojson/<?=$data_kamp->alternatif_file?>"
], {
onEachFeature: onEachFeature,
style: style(1)
},
)
.addTo(map)
.bindPopup("<?php echo '<center><b style=color:green;>' . $nama->alternatif_nama . ' ' . $th . '<br>' . '<img width=100px src=' . base_url('assets/img/check.gif') . '>' . '</b></center>'; ?> <div class='table-responsive'><table class='table table-bordered'><thead align='center'><?php foreach ($tes->result() as $tb) {$namak = $tb->nama;$isik = $tb->isi;$klask = $tb->klas;?><tr><th width='30px'><?php echo $klask; ?></th><th style='text-align:left';> <?php echo $namak; ?></th><th><?php echo $data_krit->$isik; ?></th></tr><?php }?></thead></table></div>");
<?php
}
foreach ($sedang->result_array() as $s) {
$_s = $s['alternatif_id'];
$data_kamp = $this->db->query("SELECT alternatif_file FROM alternatif WHERE alternatif_id = '$_s'")->row();
$data_krit2 = $this->db->query("SELECT * FROM kriteria WHERE alternatif_id = '$_s' and tahun='$th'")->row();
$nama = $this->db->query("SELECT alternatif_nama FROM alternatif WHERE alternatif_id = '$_s'")->row();?>
var jsonData = new L.GeoJSON.AJAX([
"<?php echo base_url() ?>assets/geojson/<?=$data_kamp->alternatif_file?>"
], {
onEachFeature: onEachFeature,
style: style(2)
}).addTo(map)
.bindPopup("<?php echo '<center><b style=color:yellow;>' . $nama->alternatif_nama . ' ' . $th . '<br>' . '<img width=100px src=' . base_url('assets/img/warning.gif') . '>' . '</b></center>'; ?> <div class='table-responsive'><table class='table table-bordered'><thead align='center'><?php foreach ($tes->result() as $tb) {$namak = $tb->nama;$isik = $tb->isi;$klask = $tb->klas;?><tr><th width='30px'><?php echo $klask; ?></th><th style='text-align:left';> <?php echo $namak; ?></th><th><?php echo $data_krit2->$isik; ?></th></tr><?php }?></thead></table></div>");
<?php
}
foreach ($tinggi->result_array() as $t) {
$_t = $t['alternatif_id'];
$data_kamp = $this->db->query("SELECT alternatif_file FROM alternatif WHERE alternatif_id = '$_t'")->row();
$data_krit3 = $this->db->query("SELECT * FROM kriteria WHERE alternatif_id = '$_t' and tahun='$th'")->row();
$nama = $this->db->query("SELECT alternatif_nama FROM alternatif WHERE alternatif_id = '$_t'")->row();?>
var jsonData = new L.GeoJSON.AJAX([
"<?php echo base_url() ?>assets/geojson/<?=$data_kamp->alternatif_file?>"
], {
onEachFeature: onEachFeature,
style: style(3)
}).addTo(map)
.bindPopup("<?php echo '<center><b style=color:red;>' . $nama->alternatif_nama . ' ' . $th . '<br>' . '<img width=100px src=' . base_url('assets/img/danger.gif') . '>' . '</b></center>'; ?> <div class='table-responsive'><table class='table table-bordered'><thead align='center'><?php foreach ($tes->result() as $tb) {$namak = $tb->nama;$isik = $tb->isi;$klask = $tb->klas;?><tr><th width='30px'><?php echo $klask; ?></th><th style='text-align:left';> <?php echo $namak; ?></th><th><?php echo $data_krit3->$isik; ?></th></tr><?php }?></thead></table></div>");
<?php
}?>
// map.attributionControl.addAttribution('Population data &copy; <a href="http://census.gov/">US Census Bureau</a>');
var legend = L.control({
position: 'bottomright'
});
legend.onAdd = function (map) {
var label = ['Tidak Rawan', 'Rawan', 'Aman'];
var div = L.DomUtil.create('div', 'info1 legend'),
grades = [1, 2, 3],
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
from = grades[i];
to = grades[i + 1];
labels.push(
'<i style="background:' + getColor(from) + '"></i>' + label[i]);
}
div.innerHTML = labels.join('<br>');
return div;
};
legend.addTo(map);
</script>
</div>
</section>
</div>
<?php $this->load->view('dist/_partials/footer');?>