Add Markers To Gmap

Hi
I create attach a Map to a Layout like that:

[code]var GMaps
var customparams = {
center: new google.maps.LatLng(44.383256,12.075348),
zoom: 11,
//disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};

//Carico la Mappa e i Parametri
GMaps=box_mappa.attachMap(customparams)[/code]

The map is attached properly.
I have some places in a MySQL database through a function that is extracted in XML.
At this point, the code below should bring up the markers on the map, but it is not. The map continues to appear, but no markers.

[code]var customIcons = {
Ospedali: {
icon: ‘http://labs.google.com/ridefinder/images/mm_20_blue.png’,
shadow: ‘http://labs.google.com/ridefinder/images/mm_20_shadow.png
},
bar: {
icon: ‘http://labs.google.com/ridefinder/images/mm_20_red.png’,
shadow: ‘http://labs.google.com/ridefinder/images/mm_20_shadow.png
}
};

var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl(“phpsqlajax_genxml.php”, function(data) {
var xml = data.responseXML;
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 google.maps.LatLng(
parseFloat(markers[i].getAttribute(“lat”)),
parseFloat(markers[i].getAttribute(“lng”)));
var html = “” + name + “
” + address;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}

function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
}

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}[/code]

Can you help please?
thanks

Hi,

attachMap returns map object. Therefore, you may use GMaps to add markers in map.

Can I have an example, please?

Please see googlemap API

I have done today a bit researching in a similar issue and I will now share my result with you.

This code snipped below creates a map located on an address string (no knowledge of the latitude/longitude is needed) and will also create there a marker with an info window.

      var opts = {
          center: new google.maps.LatLng(47.349814818445935,8.275355100631714),
          zoom: 16,
          mapTypeId: google.maps.MapTypeId.ROADMAP
      };
    GMaps = dhxLayout.cells('a').attachMap(opts);
      var geocoder = new google.maps.Geocoder();
      geocoder.geocode( { 'address': 'Sedova str. 80, Saint Petersburg, Russia'}, function(results, status) {
            GMaps.setCenter(results[0].geometry.location);
                  var marker = new google.maps.Marker({
                      position: results[0].geometry.location,
                      title:"dhtmlx Mailing Address"
                  });
                  marker.setMap(GMaps);
                  var infowindow = new google.maps.InfoWindow({
                      content: '<b>dhtmlx</b>'
                  });
                  infowindow.open(GMaps,marker);
    });