title: Fetch Latitude and Longitude from MySQL for show Google Map
body: <p>I am new in google map things, i have stored latitude and longitude in database MySQL. I want to show google map with latitude and longitude i had. 
  This is my ajax code to get latitude and longitude from database</p>
  
  <pre><code>$.ajax({
              url: 'phpmobile/getlanglong.php',
              data: { "id": getacara},
              dataType: 'json',
              success: function(data, status){
                  $.each(data, function(i,item){ 
                      showMap(item.latitude,item.longitude);
  
                  });
              },
              error: function(){
                  output.text('There was an error loading the data.');
              }
          }); 
  </code></pre>
  
  <p>this is my function to showMap</p>
  
  <pre><code>function showMap(_lat,_long)
  {
      var map;
  
      var myLatLng = {lat: _lat, lng: _long};
      function initMap() {
          map = new google.maps.Map(document.getElementById('map'), {
             center: {lat: _lat, lng: _long},
             zoom: 20
          });
          var marker = new google.maps.Marker({
             position: myLatLng,
             map: map,
             title: 'Hello World!'
          });
      }
  }
  </code></pre>
  
  <p>and in document ready</p>
  
  <pre><code>$( document ).ready(function() {
      showMap();
  });
  </code></pre>
  
  <p>this is my getlanglong.php</p>
  
  <pre><code>&lt;?php
  session_start();
  include "config.php";
  
  $idacara=mysql_real_escape_string($_GET["id"]);
  $mysql = ("SELECT latitude,longitude FROM `acara` WHERE id_acara='$idacara'");
  $result=mysql_query($mysql);
  if (!empty($result))
  {
  
      while ($row=mysql_fetch_array($result))
      {
          $latlong[] = array(
          'latitude' =&gt; $row['latitude'], 
          'longitude' =&gt; $row['longitude'],
          );
  
      }
  }
  
  mysql_close($con);
  
  header('Content-Type:application/json');
  echo json_encode($latlong);
  ?&gt;
  </code></pre>
  
  <p>Thank you</p>