Sabtu, 21 April 2018
Min dan MAx Array 2 Dimensi
<?php
$b=$m;//baris
$c=$n;//column
for($i=0;$i<$c;$i++){
$mins[$i]= minOfKey($arV,$i);
$maxs[$i]= maxOfKey($arV,$i);
}
==================================================================
function maxOfKey($array, $key) {
if (!is_array($array) || count($array) == 0) return false;
$max = $array[0][$key];
foreach($array as $a) {
if($a[$key] > $max) {
$max = $a[$key];
}
}
return $max;
}
function minOfKey($array, $key) {
if (!is_array($array) || count($array) == 0) return false;
$min = $array[0][$key];
foreach($array as $a) {
if($a[$key] < $min) {
$min = $a[$key];
}
}
return $min;
}
function bulat($v){
return round($v,3);
}
?>
Rabu, 18 April 2018
PHP code BubbleSort
$sortarr = array(3,5,15,3,2,6,7,50,1,4,5,2,100,9,3,2,6,7,13,18);
echo "<pre>";
// Array to be sorted
print_r($sortarr);
// Sorted Array
print_r(bubble_sort($sortarr));
echo "<pre>";
function bubble_sort($sortarr){
// Bubble sorting
$array_count = count($sortarr);
for($x = 0; $x < $array_count; $x++){
for($a = 0 ; $a < $array_count - 1 ; $a++){
if($a < $array_count ){
if($sortarr[$a] > $sortarr[$a + 1] ){
swap($sortarr, $a, $a+1);
}
}
}
}
return $sortarr;
}
function swap(&$arr, $a, $b) {
$tmp = $arr[$a];
$arr[$a] = $arr[$b];
$arr[$b] = $tmp;
}
Implementasi:<?php
function getJarak($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371000){
// convert from degrees to radians
$latFrom = deg2rad($latitudeFrom);
$lonFrom = deg2rad($longitudeFrom);
$latTo = deg2rad($latitudeTo);
$lonTo = deg2rad($longitudeTo);
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
$angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) +
cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));
$jr=($angle * $earthRadius)/1000;
return round($jr,3);
}
function swap(&$arr, $a, $b) {
$tmp = $arr[$a];
$arr[$a] = $arr[$b];
$arr[$b] = $tmp;
}
?>
$i=0;
$j=0;
foreach($awisata -> result() as $a){
$dtelp=$a->telepon;
$dnama=$a->nama_tempat_wisata;
$dalamat=$a->alamat;
$dlat=$a->latitude;
$dlon=$a->longitude;
$arN[$i]=$dnama;
$arA[$i]=$dalamat;
$arLat[$i]=$dlat;
$arLon[$i]=$dlon;
$arLinkW[$j]=base_url('index/detail_info/wisata/'.$a->id_wisata);
$arNW[$j]=$dnama;
$arJW[$j]=getJarak($lat,$lon,$dlat,$dlon);$j++;
$i++;
}
$j=0;
foreach($ahiburan -> result() as $a){
$dtelp=$a->telepon;
$dnama=$a->nama_hiburan;
$dalamat=$a->alamat;
$dlat=$a->latitude;
$dlon=$a->longitude;
$arN[$i]=$dnama;
$arA[$i]=$dalamat;
$arLat[$i]=$dlat;
$arLon[$i]=$dlon;
$arNH[$j]=$dnama;
$arLinkH[$j]=base_url('index/detail_info/hiburan/'.$a->id_hiburan);
$arJH[$j]=getJarak($lat,$lon,$dlat,$dlon);$j++;
$i++;
}
$j=0;
foreach($atm -> result() as $a){
$dtelp=$a->telepon;
$dnama=$a->nama_tempat_makan;
$dalamat=$a->alamat;
$dlat=$a->latitude;
$dlon=$a->longitude;
$arN[$i]=$dnama;
$arA[$i]=$dalamat;
$arLat[$i]=$dlat;
$arLon[$i]=$dlon;
$arNM[$j]=$dnama;
$arLinkM[$j]=base_url('index/detail_info/tm/'.$a->id_tempat_makan);
$arJM[$j]=getJarak($lat,$lon,$dlat,$dlon);$j++;
$i++;
}
$j=0;
foreach($apenginapan -> result() as $a){
$dtelp=$a->telepon;
$dnama=$a->nama_penginapan;
$dalamat=$a->alamat;
$dlat=$a->latitude;
$dlon=$a->longitude;
$arN[$i]=$dnama;
$arA[$i]=$dalamat;
$arLat[$i]=$dlat;
$arLon[$i]=$dlon;
$arNP[$j]=$dnama;
$arLinkP[$j]=base_url('index/detail_info/penginapan/'.$a->id_penginapan);
$arJP[$j]=getJarak($lat,$lon,$dlat,$dlon);$j++;
$i++;
}
$j=0;
foreach($alayanan -> result() as $a){
$dtelp=$a->telepon;
$dnama=$a->nama_tempat_layanan;
$dalamat=$a->alamat;
$dlat=$a->latitude;
$dlon=$a->longitude;
$arN[$i]=$dnama;
$arA[$i]=$dalamat;
$arLat[$i]=$dlat;
$arLon[$i]=$dlon;
$arNL[$j]=$dnama;
$arLinkL[$j]=base_url('index/detail_info/layanan/'.$a->id_layanan);
$arJL[$j]=getJarak($lat,$lon,$dlat,$dlon);$j++;
$i++;
}
<?php
echo"<b>Taman Wisata Terdekat:</b>";
$array_count = count($arJW);
for($x = 0; $x < $array_count; $x++){
for($a = 0 ; $a < $array_count - 1 ; $a++){
if($a < $array_count ){
if($arJW[$a] > $arJW[$a + 1] ){
swap($arJW, $a, $a+1);
swap($arNW, $a, $a+1);
swap($arLinkW, $a, $a+1);
}
}
}
}//for $x
echo"<ol>";
for($i=1;$i<4;$i++){
echo "<li><a href='".$arLinkW[$i]."'>".$arNW[$i]." (".$arJW[$i]." KM) </a></li>";
}
echo"</ol>";
?>
PHP detailMap + Direction
Konsep CI:
pada bagian controller/index.php
public function detail_info($modul,$id){
if($modul == "wisata"){
$this->db->join('pengelola','wisata.id_pengelola=pengelola.id_pengelola');
$this->db->join('kota','wisata.id_kota=kota.id_kota');
$this->db->join('jenis_wisata','wisata.id_jenis_wisata=jenis_wisata.id_jenis_wisata');
$data ['wisata']=$this->db->get_where('wisata',array ('id_wisata'=>$id))-> row();
}
$data ['awisata']=$this->db->get('wisata');
$data ['ahiburan']=$this->db->get('hiburan');
$data ['atm']=$this->db->get('tempat_makan');
$data ['apenginapan']=$this->db->get('penginapan');
$data ['alayanan']=$this->db->get('layanan');
$this->load->view('user/info_detail',$data);
+++++++++++++
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
</style>
<?php $this->load->view('user/header') ?>
<div class="inner_banner_agile">
</div>
<!--//banner -->
<!-- short -->
<div class="services-breadcrumb">
<div class="inner_breadcrumb">
<ul class="short_ls">
<li>
<a href="index.html">Home</a>
<span>/ /</span>
</li>
<li>Info Detail</li>
</ul>
</div>
</div>
<?php
$i=0;
foreach($awisata -> result() as $a){
$telp=$a->telepon;
$nama=$a->nama_tempat_wisata;
$alamat=$a->alamat;
$lat=$a->latitude;
$lon=$a->longitude;
$arN[$i]=$nama;
$arA[$i]=$alamat;
$arLat[$i]=$lat;
$arLon[$i]=$lon;
$i++;
}
foreach($ahiburan -> result() as $a){
$telp=$a->telepon;
$nama=$a->nama_hiburan;
$alamat=$a->alamat;
$lat=$a->latitude;
$lon=$a->longitude;
$arN[$i]=$nama;
$arA[$i]=$alamat;
$arLat[$i]=$lat;
$arLon[$i]=$lon;
$i++;
}
foreach($atm -> result() as $a){
$telp=$a->telepon;
$nama=$a->nama_tempat_makan;
$alamat=$a->alamat;
$lat=$a->latitude;
$lon=$a->longitude;
$arN[$i]=$nama;
$arA[$i]=$alamat;
$arLat[$i]=$lat;
$arLon[$i]=$lon;
$i++;
}
foreach($apenginapan -> result() as $a){
$telp=$a->telepon;
$nama=$a->nama_penginapan;
$alamat=$a->alamat;
$lat=$a->latitude;
$lon=$a->longitude;
$arN[$i]=$nama;
$arA[$i]=$alamat;
$arLat[$i]=$lat;
$arLon[$i]=$lon;
$i++;
}
foreach($alayanan -> result() as $a){
$telp=$a->telepon;
$nama=$a->nama_tempat_layanan;
$alamat=$a->alamat;
$lat=$a->latitude;
$lon=$a->longitude;
$arN[$i]=$nama;
$arA[$i]=$alamat;
$arLat[$i]=$lat;
$arLon[$i]=$lon;
$i++;
}
if(isset($wisata)){
$lat=$wisata->latitude;
$lon=$wisata->longitude;
$nama=$wisata->nama_tempat_wisata;
$alamat=$wisata->alamat;
$jenis="Wisata";
$icon="images/icon1.png";
$kota=$wisata->nama_kota;
$telepon=$wisata->telepon;
$gambar=base_url("assets/uploads/files/".$wisata -> gambar);
}
elseif(isset($hiburan)){
$lat=$hiburan->latitude;
$lon=$hiburan->longitude;
$nama=$hiburan->nama_hiburan;
$alamat=$hiburan->alamat;
$jenis="Hiburan";
$icon="images/icon2.png";
$kota=$hiburan->nama_kota;
$telepon=$hiburan->telepon;
$gambar=base_url("assets/uploads/files/".$hiburan -> gambar);
}
elseif(isset($tm)){
$lat=$tm->latitude;
$lon=$tm->longitude;
$nama=$tm->nama_tempat_makan;
$alamat=$tm->alamat;
$jenis="Tempat Makan";
$icon="images/icon2.png";
$kota=$tm->nama_kota;
$telepon=$tm->telepon;
$gambar=base_url("assets/uploads/files/".$tm -> gambar);
}
elseif(isset($penginapan)){
$lat=$penginapan->latitude;
$lon=$penginapan->longitude;
$nama=$penginapan->nama_penginapan;
$alamat=$penginapan->alamat;
$jenis="Penginapan";
$icon="images/icon2.png";
$kota=$penginapan->nama_kota;
$telepon=$penginapan->telepon;
$gambar=base_url("assets/uploads/files/".$penginapan -> gambar);
}
elseif(isset($layanan)){
$lat=$layanan->latitude;
$lon=$layanan->longitude;
$nama=$layanan->nama_tempat_layanan;
$alamat=$layanan->alamat;
$jenis="Layanan";
$icon="images/icon2.png";
$kota=$layanan->nama_kota;
$telepon=$layanan->telepon;
$gambar=base_url("assets/uploads/files/".$layanan -> gambar);
}
?>
<div class="welcome" id="about">
<div class="container">
<h3 class="title">Info</h3>
<div class="col-md-9">
<h3> Lokasi </h3><br>
<div id="floating-panel">
<b>Start: </b>
<select id="start" readonly="1">
<?php
echo"<option value='".$alamat."'>".$nama."</option>";
?>
</select>
<b>End: </b>
<select id="end">
<?php
for($j=0;$j<$i;$j++){
if($nama==$arN[$j]){}
else{
echo"<option value='".$arA[$j]."'>".$arN[$j]."</option>";
}
}
?>
</select>
</div>
<div id="map"></div>
<script>
function initMap() {
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 9,center: {lat: <?php echo $lat;?>, lng: <?php echo $lon;?>}
});
directionsDisplay.setMap(map);
var marker= new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lon;?>),
map: map,icon: '<?php echo $icon;?>'
});
marker.setTitle("<?php echo $nama."-".$alamat;?>");
attachSecretMessage(marker, "<?php echo $nama."-".$alamat;?>");
var onChangeHandler = function() {
calculateAndDisplayRoute(directionsService, directionsDisplay);
};
document.getElementById('start').addEventListener('change', onChangeHandler);
document.getElementById('end').addEventListener('change', onChangeHandler);
}
function attachSecretMessage(marker, pesan) {
var infowindow = new google.maps.InfoWindow(
{ content: pesan,size: new google.maps.Size(50,50)
});
google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker);
});
}
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({
origin: document.getElementById('start').value,
destination: document.getElementById('end').value,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
</script>
<script async defer
src="http://maps.google.com/maps/api/js?key=AIzaSyB0SZKfq2Ja2xn9XNkeApth9kHjwOimjlE&callback=initMap">
</script>
<table class="table">
<tr>
<th>Nama</th>
<td><?php echo $nama;?></td>
</tr>
<tr>
<th>Jenis</th>
<td><?php echo $jenis;?></td>
</tr>
<tr>
<th>Kabupaten/Kota</th>
<td><?php echo $kota;?></td>
</tr>
<tr>
<th>Alamat</th>
<td><label id="start2"><?php echo $alamat;?></label></td>
</tr>
</table>
</div>
<div class="col-md-3">
<h3>Gambar</h3><br>
<img src="<?php echo $gambar; ?>" alt="Beauty" class="img-responsive">
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
</div>
<?php $this->load->view('user/footer') ?>
PHP dan Fungsi Map
Dasar:
#Controller:
public function index()
{
$data ['wisata']=$this->db->get('wisata');
$data ['hiburan']=$this->db->get('hiburan');
$data ['tm']=$this->db->get('tempat_makan');
$data ['penginapan']=$this->db->get('penginapan');
$data ['layanan']=$this->db->get('layanan');
$this->load->view('user/home',$data);
}
<style type='text/css'>
#peta {
width: 100%;
height: 500px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyB0SZKfq2Ja2xn9XNkeApth9kHjwOimjlE&callback=initMap"></script>
<script type="text/javascript">
(function() {
window.onload = function() {
//Parameter Google maps
var options = {
zoom: 9, //level zoom
//posisi tengah peta
center: new google.maps.LatLng(-6.4429147,106.048433),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Buat peta di
var map = new google.maps.Map(document.getElementById('peta'), options);
//maps tempat wisata
<?php
$a=1;
$gab="[";
foreach($wisata -> result() as $a){
$link=base_url('index/detail_info/wisata/'.$a->id_wisata);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_wisata." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
var locations =<?php echo $gab;?>
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon1.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}//for i
<?php
$gab="[";
foreach($hiburan -> result() as $a){
$link=base_url('index/detail_info/hiburan/'.$a->id_hiburan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_hiburan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon2.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($tm -> result() as $a){
$link=base_url('index/detail_info/makan/'.$a->id_tempat_makan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_makan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon3.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($penginapan -> result() as $a){
$link=base_url('index/detail_info/penginapan/'.$a->id_penginapan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_penginapan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon4.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($penginapan -> result() as $a){
$link=base_url('index/detail_info/penginapan/'.$a->id_penginapan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_penginapan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon5.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($layanan -> result() as $a){
$link=base_url('index/detail_info/layanan/'.$a->id_layanan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_layanan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon5.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
//batas akhir
};
})();
</script>
hasilnya:
saat di klik detail:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
Impementasi :
Adalah sbb(CI):#Controller:
public function index()
{
$data ['wisata']=$this->db->get('wisata');
$data ['hiburan']=$this->db->get('hiburan');
$data ['tm']=$this->db->get('tempat_makan');
$data ['penginapan']=$this->db->get('penginapan');
$data ['layanan']=$this->db->get('layanan');
$this->load->view('user/home',$data);
}
<style type='text/css'>
#peta {
width: 100%;
height: 500px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyB0SZKfq2Ja2xn9XNkeApth9kHjwOimjlE&callback=initMap"></script>
<script type="text/javascript">
(function() {
window.onload = function() {
//Parameter Google maps
var options = {
zoom: 9, //level zoom
//posisi tengah peta
center: new google.maps.LatLng(-6.4429147,106.048433),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Buat peta di
var map = new google.maps.Map(document.getElementById('peta'), options);
//maps tempat wisata
<?php
$a=1;
$gab="[";
foreach($wisata -> result() as $a){
$link=base_url('index/detail_info/wisata/'.$a->id_wisata);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_wisata." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
var locations =<?php echo $gab;?>
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon1.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}//for i
<?php
$gab="[";
foreach($hiburan -> result() as $a){
$link=base_url('index/detail_info/hiburan/'.$a->id_hiburan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_hiburan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon2.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($tm -> result() as $a){
$link=base_url('index/detail_info/makan/'.$a->id_tempat_makan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_makan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon3.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($penginapan -> result() as $a){
$link=base_url('index/detail_info/penginapan/'.$a->id_penginapan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_penginapan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon4.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($penginapan -> result() as $a){
$link=base_url('index/detail_info/penginapan/'.$a->id_penginapan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_penginapan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon5.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
<?php
$gab="[";
foreach($layanan -> result() as $a){
$link=base_url('index/detail_info/layanan/'.$a->id_layanan);
$telp=$a->telepon;
if(strlen($telp<1)){$telp="-";}
$lok=$a->nama_tempat_layanan." - ".$a->alamat." Telp:".$telp;
$gab.= "['".$lok."',". $a->latitude.",".$a->longitude.",'".$link."'],";
}
$gab.="]";
$gab=str_replace("],]","]]",$gab);
?>
locations =<?php echo $gab;?>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,icon: 'images/icon5.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]+"<br><a href='"+locations[i][3]+"'>Info Detail</a>");
infowindow.open(map, marker);
}
})(marker, i));
}
//batas akhir
};
})();
</script>
hasilnya:
saat di klik detail:
Langganan:
Postingan (Atom)
Selisih Waktu Berjalan
Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...
-
<?php // <a href='download.php?file=$file' title='Download File'>Download Dokumen</a> $direktori = ...
-
Teman2 ...mungkin sering dapat kode random..... btw ini ada share sedikit ttg membuat soal random.....yang beda disini adalah sy menggunaka...
-
<?php $sql="select `id_admin` from `$tbadmin` order by `id_admin` desc"; $jum= getJum($conn,$sql); $kd="ADM"...