Anda di halaman 1dari 8

TUGAS

MATA KULIAH
SISTEM INFORMASI GEOGRAFIS

Disusun oleh :
Fatur Rachman Ardiansyah
(04319006)

FAKULTAS TEKNIK DAN ILMU KOMPUTER


UNIVERSITAS NAROTAMA
SURABAYA
2022
1. Membuat database dan tabel

CREATE DATABASE kuliner;USE kuliner;

CREATE TABLE `tempat_kuliner` (


`id_kuliner` int(10) NOT NULL AUTO_INCREMENT,
`nama_tempat` varchar(255) DEFAULT NULL,
`alamat_tempat` varchar(255) DEFAULT NULL,
`latitude` varchar(255) DEFAULT NULL,
`longitude` varchar(255) DEFAULT NULL,PRIMARY KEY
(`id_kuliner`)
);

2. Memasukkan data ke tabel

INSERT INTO `tempat_kuliner` VALUES ('1', 'SOTO AYAM CAK KUSWANTO', 'Jl.
Sidotopo Wetan Granting Bar. No.138, Simokerto, Kec. Simokerto, Kota SBY, JawaTimur 60143', '-
7.2348199', '112.7576267');
INSERT INTO `tempat_kuliner` VALUES ('2', 'Cobek Bakar Pak D', 'Jl. Sidotopo Wetan No.98-136,
Sidotopo Wetan, Kec. Kenjeran, Kota SBY, Jawa Timur 60153', '-7.2348705', '112.7576441');
INSERT INTO `tempat_kuliner` VALUES ('3', 'Warung Cak Wi', 'Jl. Sidotopo WetanNo.90, Simokerto,
Kec. Kenjeran, Kota SBY, Jawa Timur 60128', '-7.2368445', '112.7578352');
INSERT INTO `tempat_kuliner` VALUES ('4', 'Sidowareg Penyetan & Ikan Bakar', 'Jl.Sidoyoso I No.2,
Simokerto, Kec. Simokerto, Kota SBY, Jawa Timur 60143', '- 7.2387936', '112.7584038');
INSERT INTO `tempat_kuliner` VALUES ('5', 'Ayam Goreng Rempah de Vita', 'Jl. Tenggumung Karya
Gg. Lebar No.49, Pegirian, Kec. Semampir, Kota SBY, Jawa Timur60153', '-7.2259489', '112.7566845');
INSERT INTO `tempat_kuliner` VALUES ('6', 'Pecel Bu Yuli', 'Jl. Bulak Banteng KidulNo.8a, Sidotopo
Wetan, Kec. Kenjeran, Kota SBY, Jawa Timur 60128', '-7.2210408', '112.7610458');
INSERT INTO `tempat_kuliner` VALUES ('7', 'Ayam Bakar Madu RAJA AMPAT','Gg. Encap No.80,
Bulak Banteng, Kec. Kenjeran, Kota SBY, Jawa Timur 60127', '- 7.2217433', '112.7618827');
INSERT INTO `tempat_kuliner` VALUES ('8', 'Bakso Ronggolawe', 'Jl. Bulak Banteng Baru Lorong 4
No.32, RT.001/RW.02, Bulak Banteng, Kec. Kenjeran, Kota SBY, Jawa Timur 60127', '-7.2136646',
'112.7627839');
INSERT INTO `tempat_kuliner` VALUES ('9', 'Bebek Dahlia', 'Jl. Wonosari, LorongKebon 3 No.1,
Wonokusumo, Semampir, Wonokusumo, Kec. Semampir, Kota SBY, Jawa Timur 60154', '-
7.2163363', '112.7539541');
INSERT INTO `tempat_kuliner` VALUES ('10', 'Mie Gledek', 'Randu Agung Gg. I No.62, Sidotopo
Wetan, Kec. Kenjeran, Kota SBY, Jawa Timur 60128', '-7.2238082','112.7620221');

3. Membuat file koneksi.php

<?php mysql_connect("localhost","root","");
mysql_select_db("kuliner");
?>

4. Membuat file data-xml.php

<?php
header('Content-type: text/xml');
header('Pragma: public'); header('Cache-
control: private');

include("koneksi.php");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";echo


"<markers>";
$sql="select * from tempat_kuliner";
$query=mysql_query($sql) or die(mysql_error());while
($data=mysql_fetch_array($query)) {
echo "<marker id_kuliner='".$data['id_kuliner']."' nama_tempat='".$data['nama_tempat']."'
alamat_tempat='".$data['alamat_tempat']."'latitude='".$data['latitude']."' longitude='".
$data['longitude']."'/>";
}
echo "</markers>";

5. Membuat file latihan1.php

<!DOCTYPE html>
<html>
<head>
<title>Tempat Kuliner </title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 80%;
width: 80%;
margin: 0 auto 0 auto;
}
html, body {
height: 100%;
}
</style>
</head>
<body>
<h2 align="center">Tempat Kuliner Surabaya</h2>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(-7.213845,112.760953),
zoom: 12
});
var infoWindow = new google.maps.InfoWindow;

downloadUrl('http://localhost/blog/maps/data-xml.php', function(data) {var


xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName('marker');

Array.prototype.forEach.call(markers, function(markerElem) {var


id_kuliner = markerElem.getAttribute('id_kuliner');
var nama_tempat = markerElem.getAttribute('nama_tempat'); var
alamat_tempat = markerElem.getAttribute('alamat_tempat');var
point = new google.maps.LatLng(
parseFloat(markerElem.getAttribute('latitude')),
parseFloat(markerElem.getAttribute('longitude')));

var infowincontent = document.createElement('div');var


strong = document.createElement('strong');
strong.textContent = nama_tempat
infowincontent.appendChild(strong);
infowincontent.appendChild(document.createElement('br'));

var text = document.createElement('text');


text.textContent = alamat_tempat
infowincontent.appendChild(text);
var marker = new google.maps.Marker({
map: map,
position: point
});
marker.addListener('click', function() {
infoWindow.setContent(infowincontent);
infoWindow.open(map, marker);
});
});
});
}

function downloadUrl(url, callback) { var


request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :new
XMLHttpRequest;
request.onreadystatechange = function() { if
(request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
</script>
<script src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyCm_t75G1HRTGvFPaP95i3t
UOpdRNWFYbE&callback=initMap”
async defer></script>
</body>
</html>

6. Membuat file data-json.php

<?php
header('Content-Type: application/json; charset=utf8');
//panggil koneksi.php
include("koneksi.php");

$sql="SELECT * FROM tempat_kuliner";


$query=mysql_query($sql) or die(mysql_error());

$array=array();
while($data=mysql_fetch_assoc($query)) $array[]=$data;

echo json_encode($array);
?>

7. Membuat file latihan2.php

<!DOCTYPE html>
<html>
<head>
<title>Tempat Kuliner </title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 80%;
width: 80%;
margin: 0 auto 0 auto;
}
html, body {
height: 100%;
}
</style>
</head>
<body>
<h2 align="center">Tempat Kuliner Surabaya</h2>
<script>

function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(-7.213845,112.760953),
zoom: 12
});
var infoWindow = new google.maps.InfoWindow;

downloadUrl('http://localhost/blog/maps/data-json.php', function(data) {

var markers=JSON.parse(data.responseText);
markers.forEach(function(element) {
var id_kuliner = element.id_kuliner;
var nama_tempat = element.nama_tempat; var
alamat_tempat = element.alamat_tempat;var
point = new google.maps.LatLng(
parseFloat(element.latitude),
parseFloat(element.longitude));
var infowincontent = document.createElement('div');var
strong = document.createElement('strong');
strong.textContent = nama_tempat
infowincontent.appendChild(strong);
infowincontent.appendChild(document.createElement('br'));

var text = document.createElement('text');


text.textContent = alamat_tempat
infowincontent.appendChild(text);
var marker = new google.maps.Marker({map:
map,
position: point
});
marker.addListener('click', function() {
infoWindow.setContent(infowincontent);
infoWindow.open(map, marker);
});
});
});
}
function downloadUrl(url, callback) { var
request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :new
XMLHttpRequest;

request.onreadystatechange = function()if
(request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMa p"
async defer></script>
</body>
</html>
Hasil

Anda mungkin juga menyukai