## jMaps

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.

### Example 1: Passing an address string.

Example: Address Search Form Address:

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

### Example 2: Reverse Geocoding a point.

Example: Reverse Geocode Point Point:

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