Title: how to use latitude and longitude value from my database to show on google map?
Tags: javascript;php;mysql;google-maps;google-maps-api-3
Question: I have sample code. It is calling latitude and longitude value and marking it on maps.
But i want my all record latitude and longitude show on maps not just one. I know i need change my code for call all value (i must use while or foreach) it is ok but i don't know how can i add it on map and i need like MarkerClusterer Cause i have many value on database.
I did a search but did not succeed.
Regards
My Code:
<?php
include_once("db.php");
$db=new database;
$query= mysql_query("SELECT * FROM firsatlar");
$array=mysql_fetch_array($sorgu);
$place=explode(":", $array["latLngs"],2);
$lat= $place[0]; //latitude
$lng= $place[1]; //longitude
<!DOCTYPE html&gt;
<html&gt;
<head&gt;
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
<meta charset="utf-8"&gt;
<title&gt;Info windows</title&gt;
<style&gt;
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style&gt;
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;</script&gt;
<script&gt;
function initialize() {
var myLatlng = new google.maps.LatLng(<?php echo $lat?&gt;,<?php echo $lng?&gt;);
var mapOptions = {
zoom: 4,
center: myLatlng
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var contentString = '<div id="content"&gt;'+
'<div id="siteNotice"&gt;'+
'</div&gt;'+
'<h1 id="firstHeading" class="firstHeading"&gt;</h1&gt;'+
'<div id="bodyContent"&gt;'+
'<p&gt;<b&gt;Uluru</b&gt;, also referred to as <b&gt;Ayers Rock</b&gt;, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335&amp;#160;km (208&amp;#160;mi) '+
'south west of the nearest large town, Alice Springs; 450&amp;#160;km '+
'(280&amp;#160;mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p&gt;'+
'<p&gt;Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&amp;oldid=297882194"&gt;'+
'http://en.wikipedia.org/w/index.php?title=Uluru</a&gt; '+
'(last visited June 22, 2009).</p&gt;'+
'</div&gt;'+
'</div&gt;';
var infowindow = new google.maps.InfoWindow({
content: contentString
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Uluru (Ayers Rock)'
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
google.maps.event.addDomListener(window, 'load', initialize);
</script&gt;
</head&gt;
<body&gt;
<div id="map-canvas"&gt;</div&gt;
</body&gt;
</html&gt;

Here is the accepted answer: Query your database with AJAX. Loop through the results to create each marker. There are plenty of examples around. Then you can refer to the MarkerClusterer documentation http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html to create your marker clusters.
Comment for this answer: Well you need to go step by step here. Take a simple example of an AJAX request to a PHP page, try to understand how it works, etc. You don't get downvotes because your question is too simple, but because it has been answered already or because you did not put enough effort to make it clear.
Comment for this answer: Thank you for answer @MrUpsidown. I saw that documentation but my knowledge is not enough for do that. I don't know how can i do it with my code. You can see people are give negative point my question maybe too simple for them. Thank you again for taking the time

Here is another answer: A simple solution is a marker cluster in php:http://www.appelsiini.net/2008/introduction-to-marker-clustering-with-google-maps.
Comment for this answer: Thanks for answer. I don't know good php and how can i integrate it on my code can you help me about it?

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:01/13/14', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<javascript><php><mysql><google-maps><google-maps-api-3>', 'Title': 'how to use latitude and longitude value from my database to show on google map?', 'ViewCount': 2798, 'id': 21099856, 'user_AboutMe': "<p>I'm grocer. I'll be glad if you help me on the web development.</p>\n\n<p>Erdal Bakkal</p>\n", 'user_AccountId': 3463429.0, 'user_DisplayName': 'Erdal Bakkal', 'user_Reputation': 325.0, 'user_Views': 94.0, 'user_id': 2899762.0}}