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;
}