This example shows you how easily jQuery + jMaps makes searching for an address.
The Google Geocoder supports both passing a string address and a GLatLng point. Example 1 shows passing an address while Example 2 shows reverse geocoding with a GLatLng.
jQuery(document).ready(function(){
jQuery('#map1').jmap('init', {'mapType':G_HYBRID_MAP,'mapCenter':[37.4419, -122.1419]});
jQuery('#address-submit-1').click(function(){
jQuery('#map1').jmap('SearchAddress', {
'query': jQuery('#address').val(),
'returnType': 'getLocations'
}, function(result, options) {
var valid = Mapifies.SearchCode(result.Status.code);
if (valid.success) {
jQuery.each(result.Placemark, function(i, point){
jQuery('#map1').jmap('AddMarker',{
'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
'pointHTML':point.address
});
});
} else {
jQuery('#address').val(valid.message);
}
});
return false;
});
});
jQuery('#point-submit-1').click(function(){
var points = jQuery('#point').val().split(',');
jQuery('#map2').jmap('SearchAddress', {
'query': new GLatLng(points[0], points[1]),
'returnType': 'getLocations'
}, function(result, options) {
var valid = Mapifies.SearchCode(result.Status.code);
if (valid.success) {
jQuery.each(result.Placemark, function(i, point){
jQuery('#map2').jmap('AddMarker',{
'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
'pointHTML':point.address
});
});
} else {
jQuery('#point').val(valid.message);
}
});
return false;
});
});