Google map is not displaying markers



I working with google maps. but the markers are not displaying.

Here is the code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps AJAX + MySQL/PHP Example</title>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
var iconBlue = new GIcon(); 
iconBlue.image = "";
iconBlue.shadow = "";
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);
var iconRed = new GIcon(); 
iconRed.image = "";
 iconRed.shadow = "";
iconRed.iconSize = new GSize(12, 20);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);
var customIcons = [];
customIcons["restaurant"] = iconBlue;
customIcons["bar"] = iconRed;
function load() 
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(17.408446, 78.448692), 16);
GDownloadUrl("phpsqlajax.php", function(data,responseCode)
var xml = GXml.parse(data);
var markers=xml.documentElement.getElementsByTagName("marker"); 
for (var i = 0; i < markers.length; i++) 
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var point = new
GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute( "lng")));
var marker = createMarker(point, name, address, type);
function createMarker(point, name, address, type)
 var marker = new GMarker(point, customIcons[type]);
var html = "<b>" + name + "</b> <br/>" + address;
GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });
return marker;
<body onload="load()" onunload="GUnload()">
 <div id="map" style="width: 500px; height: 300px"></div>

please help me out to resolve this issue

Thanks & regards.


The image you’re using, [noparse][/noparse] doesn’t exist. It should be[COLOR="Red"]_20[/COLOR]_blue.png :slight_smile:



I had change the image pathm but then also the markers are not displaying.

please help me out

Thanks and Regards


var customIcons = [];
customIcons["restaurant"] = iconBlue;
customIcons["bar"] = iconRed;

You can’t do that in javascript. It should be:

var customIcons = {
  restaurant: icon,
  bar: iconRed

Try that :slight_smile:


I tried your suggestion. but no luck. still it is not displaying the markers.

please help me out

Is the map live on a website somewhere so I can take a look? Just looking at the source code only goes so far :slight_smile:


I am check the map on my localhost.

thanks & Regards


I will see what I can do later today. Right now I’m rather busy.

So if anyone else wants to take a stab, go for it :slight_smile:

I can’t really test it here because I don’t have your phpsqlajax.php
Could you post an example output of that file here so I can use that please?