diff --git a/README.md b/README.md index 1018f06..a055dad 100644 --- a/README.md +++ b/README.md @@ -108,22 +108,15 @@ With Gravity Forms installed, you can install this plugin in the usual WordPress ### Creating your first Geocoding field -1. (Optional) Visit the Gravity Forms settings page enter a Geocod.io or -Google Maps API key, or to change which email is sent with OSM Nominatim API calls. +1. (Optional) Visit the Gravity Forms settings page enter a Geocod.io or Google Maps API key, or to change which email is sent with OSM Nominatim API calls. 2. Create a new Gravity Form (or edit an existing one). -3. (Optional) Visit the form settings page and select which geocoder to use. -It will use OSM Nominatim by default. +3. (Optional) Visit the form settings page and select which geocoder to use. It will use OSM Nominatim by default. 4. Add the input fields you want the user to fill out. 5. Add the Geocoder field (under the Advanced Fields tab). -6. In the Geocoder field associate the geocoder parameters with the other input -fields on your form. -7. Publish your form and add it to a page like you would any other Gravity -Form! - -and add the Geocoder field from the Advanced Fields -menu. Add other input fields, then in the Geocoder settings select which -fields will be used as parameters for the geocoding. - +6. In the Geocoder field associate the geocoder parameters with the other input fields on your form. +7. Publish your form and add it to a page like you would any other Gravity Form! +8. Add the non-Geocoding input fields. +9. Add the Geocoder field from the Advanced Fields menu and in the field settings select which fields will be used as parameters for the geocoding. Frequently Asked Questions -------------------------- @@ -151,17 +144,27 @@ If you create users or posts, and set a meta value to the value of a Brilliant Geocoder field, that value will be stored as spatial metadata. Brilliant Geocoder for Gravity Forms uses WP-GeoMeta internally. For sample -queries, please see the [WP-GeoMeta documentation](https://github.com/cimburadotcom/wp-geometa#querying). +queries, please see the [WP-GeoMeta documentation](https://github.com/brillliantplugins/wp-geometa#querying). ### Where can I get help with GIS and WordPress? For commercial support you can contact the plugin developer at -[Cimbura.com](https://cimbura.com/contact-us/project-request-form/) +[luminfire.com](https://luminfire.com/contact-us/project-request-form/) For fast and short questions you can [contact me](https://twitter.com/stuporglue) on twitter. Changelog --------- += 0.0.3 = +* Improved Handling of Google Maps API +* Added support for Gravity Forms v2.4+ + += 0.0.2 = +* Updated wp-geometa-lib. +* Updated readme documentation. +* Tested with WP 4.8 +* Some additional debugging code. +* Fixed Google Geocoder. = 0.0.1 = * Initial release! diff --git a/brilliant-geocoder-gravityforms.php b/brilliant-geocoder-gravityforms.php index 92804c4..3ec8b6f 100644 --- a/brilliant-geocoder-gravityforms.php +++ b/brilliant-geocoder-gravityforms.php @@ -32,6 +32,7 @@ function geocoder_for_gf_init() { require_once( __DIR__ . '/lib/class-geocoder-gravity-settings.php' ); require_once( __DIR__ . '/lib/class-geocoder-gravity-field.php' ); + $wpgm_loader = __DIR__ . '/lib/wp-geometa-lib/wp-geometa-lib-loader.php'; if ( !file_exists( $wpgm_loader ) ) { error_log( __( "Could not load wp-geometa-lib. You probably cloned wp-geometa from git and didn't check out submodules!", 'brilliant-geocoder-gravityforms' ) ); diff --git a/geocoders/google_maps_api.js b/geocoders/google_maps_api.js index 34b5880..1436a20 100644 --- a/geocoders/google_maps_api.js +++ b/geocoders/google_maps_api.js @@ -1,18 +1,34 @@ window.gfg_geocoder_engines.google_maps_api = function( args, success_callback, failure_callback ) { + var params = {}; + var address = []; + var key = ''; + + // Split the address and the key into their own parameters + jQuery.each(args, function( index, value ){ + if ( index != 'key' ) { + address.push(value); + } else { + key = value; + } + }) + + address = address.join(' '); + params.address = address; + params.key = key // Make an API call and call the appropriate callback function. - jQuery.get('https://maps.googleapis.com/maps/api/geocode/json?' + jQuery.param( args ), function( success ) { + jQuery.get('https://maps.googleapis.com/maps/api/geocode/json?' + jQuery.param( params ), function( success ) { if ( success.status !== 'OK' ) { failure_callback( success ); return; } - + var geojson = ''; if ( success.results.length > 0 ) { var res = success.results[0]; - + // Build a GeoJSON object. geojson = { 'type': 'Feature', diff --git a/geocoders/google_maps_api.php b/geocoders/google_maps_api.php index cf90013..4b9f8d7 100644 --- a/geocoders/google_maps_api.php +++ b/geocoders/google_maps_api.php @@ -9,7 +9,12 @@ function gfg_gmapi_fields( $fields ) { $fields['Google Maps API'] = array( - 'address' => 'Search Field', + 'street' => 'Street', + 'city' => 'City', + 'county' => 'County', + 'state' => 'State', + 'postalcode' => 'Postal Code', + 'countrycode' => 'ISO 3166-1alpha2 Country Code', ); return $fields; @@ -37,7 +42,7 @@ function gfg_gmapi_keys( $keys, $geocoding_engine, $form ) { // Since the geocodio engine is in use, enqueue the file $base_url = plugins_url( '', dirname( __FILE__ ) ); - wp_enqueue_script( 'geocoder_geocodio', $base_url . '/geocoders/google_maps_api.js', array( 'gfg_geocode' ), filemtime( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'google_maps_api.js' ) ); + wp_enqueue_script( 'geocoder_googlemaps', $base_url . '/geocoders/google_maps_api.js', array( 'gfg_geocode' ), filemtime( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'google_maps_api.js' ) ); $gfg = Geocoder_for_Gravity::get_instance(); $settings = $gfg->get_plugin_settings(); diff --git a/lib/class-geocoder-gravity-field.php b/lib/class-geocoder-gravity-field.php index bab6cba..104dc32 100644 --- a/lib/class-geocoder-gravity-field.php +++ b/lib/class-geocoder-gravity-field.php @@ -110,6 +110,8 @@ public function get_field_input( $form, $value = '', $entry = null ) { $is_form_editor = $this->is_form_editor(); $logic_event = version_compare( GFForms::$version, '2.4-beta-1', '<' ) ? $this->get_conditional_logic_event( 'keyup' ) : ''; + $tabindex = $this->get_tabindex(); + $id = (int) $this->id; $field_id = $is_entry_detail || $is_form_editor || 0 === $form_id ? "input_$id" : 'input_' . $form_id . "_$id"; @@ -284,7 +286,7 @@ public function gform_field_standard_settings( $position, $form_id ) { print '
Configure the mapping for the ' . esc_html( $which_geocoder ) . ' eocoding service.
'; + print 'Configure the mapping for the ' . esc_html( $which_geocoder ) . ' geocoding service.
'; print '