cahyadsn

icon peta

Jun 11th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Project </title>
  5. <style type='text/css'>
  6. #peta {
  7.   width: 85%;
  8.   height: 500px;
  9. }
  10. </style>
  11. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  12. <script type="text/javascript">
  13. (function() {
  14.   window.onload = function() {
  15.     var map;
  16.     var locations = [
  17.     <?php
  18.     mysql_connect('localhost','root','');
  19.     mysql_select_db('lokasi');
  20.     $sql_lokasi="SELECT nama,lat,lon, owner FROM lokasi1 ";
  21.     $result=mysql_query($sql_lokasi1);
  22.     $dt=array();
  23.     while($data=mysql_fetch_object($result)){
  24.       $dt[]="['{$data->nama}',{$data->lat}, {$data->lon},'{$data->owner}']";
  25.     }
  26.     echo implode(",",$dt);
  27.     ?>
  28.     ];
  29.     var options = {
  30.       zoom: 9,
  31.       center: new google.maps.LatLng(-7.248397400000001000, 107.909651599999960000),
  32.       mapTypeId: google.maps.MapTypeId.ROADMAP
  33.     };
  34.     var map = new google.maps.Map(document.getElementById('peta'), options);
  35.     var infowindow = new google.maps.InfoWindow();
  36.     var marker, i;
  37.     for (i = 0; i < locations.length; i++) {
  38.       marker = new google.maps.Marker({
  39.         position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  40.         map: map,
  41.         icon: (locations[i][3]=='DMT'?'tb.png':(locations[i][3]=='Protelindo'?'tp.png':'tt.png'))
  42.       });
  43.       google.maps.event.addListener(marker, 'click', (function(marker, i) {
  44.         return function() {
  45.           infowindow.setContent(locations[i][0]);
  46.           infowindow.open(map, marker);
  47.         }
  48.       })(marker, i));
  49.     }
  50.   };
  51. })();
  52. </script>
  53. </head>
  54. <body>
  55. <div id="peta"></div>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment