A: 

I would recommend using this extension (JS library): http://www.pixeldevelopment.com/pdmarker.asp

for coordinates, you would need to do geocoder via google API to fetch the correct coordinates for the city desired.

dusoft
+1  A: 

Hi,

If you have just city name or address, Use the following function:

var map = new GMap2(document.getElementById("map"));
var geocoder = new GClientGeocoder();

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(address);
      }
    }
  );
}

Or else if you have all the values as required below use the following code:

var json_loc = { "locationName": "xxxx", "locationAddress": "xxxx", "latitude": xxxx, "longitude": xxxx };

If you have the above values you can use the following functions to have google maps.

var map = new GMap2(document.getElementById("map"));
var point = new GLatLng(json_loc.latitude, json_loc.longitude);
var locationName = json_loc.locationName;
var locationAddress = json_loc.locationAddress;
map.setCenter(point, 14);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addOverlay(locationView.createMarker(point, locationName, locationAddress));
// Creates a marker whose info window displays the letter corresponding 
// to the given index.
createMarker: function(point, locationName, locationAddress) {
    var marker = new GMarker(point); 
    GEvent.addListener(marker, "mouseover", function() {
     marker.openInfoWindowHtml("<b>" + locationName + "</b><br>" + locationAddress);
    });
    return marker;
}
kayteen
A: 

This is the simplest way to add a marker to a map.

var point = new GLatLng(40,10);
var marker = new GMarker(point);
map.addOverlay(marker);
Chris B