c. Cari Obyek Wisata
Tampilan berikut ini adalah tampilan halaman pencarian tempat wisata, di mana user dapat mencari tempat
wisata berdasarkan masukan nama tempat wisata yang dicari.
Gambar 4. 18 Halaman Cari Obyek Wisata.
Listing program untuk melakukan pencarian obyek wisata.
1. script
2. function initMap {
3. var mapCanvas = document.getElementByIdgoogleMap;
4. var mapOption = {
5. zoom: 1,
6. MapType: google.maps.MapTypeId.ROADMAP
7. };
8. var map = new google.maps.MapmapCanvas, mapOption;
9. var infoWindow = new google.maps.InfoWindow{map:
map}; 10. var bounds = new google.maps.LatLngBounds;
11. var directionsService = new google.maps.DirectionsService; 12. var directionsDisplay = new google.maps.DirectionsRenderer{
13. draggable: true, 14. map: map,
15. panel: document.getElementByIddirectionsPanel 16. };
17. ?php 18. include ..Koneksikoneksi.php;
19. 20. if isset_POST[Namawisata] {
21. namawisata = _POST[Namawisata]; 22. ser = SELECT FROM Wisata where Nama_wisata like
namawisata;
23. result = mysqli_queryconn, ser; 24. if ser === {
25. echo error; 26. echo script language=javascriptalertgsahkskddnscript;
27. echo
script language=javascriptwindow.location
= HalamanWisata.phpscript;
28. } else { 29. foreach result as row {
30. koord_x = row[Latitude]; 31. koord_y = row[Longtitude];
32. namawis = row[Nama_wisata]; 33. Alamat = row[Alamat];
34. Harga = row[Harga]; 35. Notlp = row[No_tlp];
36. Keterangan = row[Keterangan]; 37. Pengelola = row[Nama_Pengelola];
38. Idwisata = row[Id_wisata]; 39. BtnLihat
= div
class=btn-group inlineform
action=..LihatGambar.php method=GET 40. . button type=submit class=btn btn-info btn-sm inline
value= . Pengelola . Lihat Gambarbutton 41. . formdiv;
42. btnTujuan1 =
div class=btn-group
inlineform action=HalamanWisata.php method=POST
43. . input type=hidden name=latid value= . koord_x . 44. . input type=hidden name=logit value= . koord_y .
45. . nbspbutton type=submit class=btn btn-info btn-sm inlineLihat Rute Ke Sinibutton
46. . formdiv; 47. echo addMarkerkoord_x, koord_y, brNama Obyek Wisata :
namawis, brAlamat : Alamat, brBiaya Masuk : Harga, brNo Telp
: Notlp,brKeterangan
: Keterangan,brBtnLihat,
brbtnTujuan1\n; 48. }
49. } 50. } else if isset_POST[Namawisata] {
51. result = mysqli_queryconn, SELECT FROM Wisata; 52. if result === FALSE {
53. echo script language=javascriptalertData Hotel Berhasil
Disimpanscript; 54. echo
script language=javascriptwindow.location
= HalamanWisata.phpscript;
55. echo error; 56. } else {
57. foreach result as row { 58. Idwisata = row[Id_wisata];
59. koord_x = row[Latitude]; 60. koord_y = row[Longtitude];
61. namawis = row[Nama_wisata]; 62. Alamat = row[Alamat];
63. Harga = row[Harga]; 64. Notlp = row[No_tlp];
65. Keterangan = row[Keterangan]; 66. Pengelola = row[Nama_Pengelola];
67. BtnLihat = div class=btn-group inline 68. . a href=..LihatGambar.php?Id_wisata= . Idwisata .
69. . button type=button Lihat Informasibutton 70. . a
71. . div; 72. btnTujuan1
= div
class=btn-group inlineform
action=HalamanWisata.php method=POST 73. . input type=hidden name=latid value= . koord_x .
74. . input type=hidden name=logit value= . koord_y . 75. . nbspbutton type=submit class=btn btn-info btn-sm
inlineLihat Rute Ke Sinibutton 76. . formdiv;
77. echo addMarkerkoord_x, koord_y, brNama Obyek Wisata : namawis, brAlamat : Alamat, brBiaya Masuk :
Harga, brNo
Telp :
Notlp,brKeterangan :
Keterangan,brBtnLihat, brbtnTujuan1\n; 78. } }
79. } else if _POST[latid] _POST[logit] { 80. latid1 = _POST[latid];
81. logit1 = _POST[logit]; 82. result = mysqli_queryconn, SELECT FROM Wisata WHERE
Latitude=latid1 AND Longtitude=logit1; 83. if result === FALSE {
84. echo script language=javascriptalertData Hotel Berhasil Disimpanscript;
85. echo script
language=javascriptwindow.location =
HalamanWisata.phpscript; 86. echo error;
87. } else { 88. foreach result as row {
89. Idwisata = row[Id_wisata]; 90. koord_x = row[Latitude];
91. koord_y = row[Longtitude]; 92. namawis = row[Nama_wisata];
93. Alamat = row[Alamat]; 94. Harga = row[Harga];
95. Notlp = row[No_tlp]; 96. Keterangan = row[Keterangan];
97. Pengelola = row[Nama_Pengelola]; 98. BtnLihat = div class=btn-group inline
99. . a href=..LihatGambar.php?Id_wisata= . Idwisata . 100. . button type=button Lihat Informasibutton
101. . a 102. . div;
103.btnTujuan1 =
div class=btn-group
inlineform action=HalamanWisata.php method=POST
104. . input type=hidden name=latid value= . koord_x . 105. . input type=hidden name=logit value= . koord_y .
106. . nbspbutton type=submit class=btn btn-info btn-sm inlineLihat Rute Ke Sinibutton
107. . formdiv; 108. echo addMarkerkoord_x, koord_y, brNama Obyek Wisata :
namawis, brAlamat : Alamat, brBiaya Masuk : Harga, brNo Telp
: Notlp,brKeterangan
: Keterangan,brBtnLihat,
brbtnTujuan1\n; } 109.if navigator.geolocation {
110. navigator.geolocation.getCurrentPosition 111. functionposition {
112. var pos
= {lat:
position.coords.latitude, lng:
position.coords.longitude}; 113. var xi = position.coords.latitude;
114. var yi = position.coords.longitude; 115. infoWindow.setPositionpos;
116.if isset_POST[latid] isset_POST[logit] { 117. lat2 = _POST[latid];
118. long2 = _POST[logit]; 119. ?
120. displayRoutexi + , + yi, ?php echo lat2,
long2; ?, directionsService, 121. directionsDisplay;
122. ?php 123.} else {
124. ? 125. displayRoutexi + , + yi, ?php echo koord_x,
koord_y; ?, directionsService, 126. directionsDisplay;
127.?php } ? 128. infoWindow.setContentLocation found : + xi + , + yi + ;
129. map.setCenterpos; 130. },
131. function { 132. handleLocationErrortrue,
infoWindow, map.getCenter;
133. }; 134. } else {
135. handleLocationErrorfalse, infoWindow, map.getCenter; 136. }
137. directionsDisplay.addListenerdirections_changed, function { 138. computeTotalDistancedirectionsDisplay.getDirections;
139. }; 140. function displayRouteorigin, destination, service, display {
141. service.route{ 142. origin: origin,
143. destination: destination, 144. travelMode: google.maps.TravelMode.DRIVING
145. }
146. infoWindow.setContentLocation found : + xi + , + yi + ; 147. map.setCenterpos;
148. }, 149. function {
150. handleLocationErrortrue, infoWindow, map.getCenter; 151. };
152. } else { 153. handleLocationErrorfalse, infoWindow, map.getCenter;
154. } 155. directionsDisplay.addListenerdirections_changed, function {
156. computeTotalDistancedirectionsDisplay.getDirections; 157. };
158. function displayRouteorigin, destination, service, display { 159. service.route{
160. origin: origin, 161. destination: destination,
162. travelMode: google.maps.TravelMode.DRIVING 163. }
164. , functionresponse, status { 165. if status === google.maps.DirectionsStatus.OK {
166. display.setDirectionsresponse; 167. } else {
168. if status === INVALID_REQUEST { 169. alerttesting;
170. } 171. else {
172. alertxi; 173.function computeTotalDistanceresult {
174. var total = 0; 175. var myroute = result.routes[0];
176. for var i = 0; i myroute.legs.length; i++ { 177. total += myroute.legs[i].distance.value;
178. } 179. total = total 1000;
180. document.getElementByIdtotal.innerHTML = total + km; 181. }
182. function
handleLocationErrorbrowserHasGeolocation, infoWindow, pos {
183. infoWindow.setPositionpos; 184. infoWindow.setContentbrowserHasGeolocation ?
185. Error: The Geolocation service failed. : 186. Error: Your browser doesn\t support geolocation.;
187.function infowindomarker, map, Infowindow, data { 188. google.maps.event.addListenermarker, mouseover, function {
189. 190. Infowindow.setContentdata;
191. Infowindow.openmap, marker; 192.
193. }; 194. }
195. 196. function addMarkerkoord_x, koord_y, Nama_wisata, Alamat, Harga,
No_tlp, Keterangan, btn1, btn2 { 197. var maps = new google.maps.LatLngkoord_x, koord_y;
198. bounds.extendmaps; 199. var markerType = new google.maps.Marker{
200. map: map, 201. position: maps,
202. icon: ..Gambarg4204.png 203. };
204. 205. map.fitBoundsbounds;
206. infowindomarkerType, map, infoWindow, Nama_wisata + Alamat
+ Harga + No_tlp + Keterangan + btn1 + btn2; 207.
208. } 209. }
210. google.maps.event.addDomListenerwindow, load, initMap; 211. script
d. Cari Rute Tempat Wisata