Google Map Field Autocomplete

This topic contains 27 reply and 4 voices, and was last updated by Tareq Hasan 11 years, 6 months ago
Viewing 15 Posts - 1 through 15 (of 27 total)
Author Posts
April 17, 2013 at 7:49 am 2327
Tareq Hasan Hi Tareq ! Is there a way to add autocompletion to the google address field ? It woul be very usefull :) !   Thanks !
April 17, 2013 at 11:31 am 2342
Tareq Hasan Tareq Hasan

I think it can be done, thanks for the suggestion.

April 18, 2013 at 7:37 am 2423
noomia noomia

Will you plan to add this 🙂 ? I think it could be great ! I’ve done this in a project, but would like to see that in WPUF 🙂

April 22, 2013 at 1:45 pm 2703
noomia noomia

Is there a way to do that right now ?

April 22, 2013 at 8:47 pm 2739
Tareq Hasan Tareq Hasan

Feature has been landed a quick fix 😉

Insert this JS snippet in the `/class/render-form.php`.
[js]
function autoCompleteAddress(){
if (!$input_add) return null;

$input_add.autocomplete({
source: function(request, response) {
// TODO: add ‘region’ option, to help bias geocoder.
geocoder.geocode( {‘address’: request.term }, function(results, status) {
response(jQuery.map(results, function(item) {
return {
label : item.formatted_address,
value : item.formatted_address,
latitude : item.geometry.location.lat(),
longitude : item.geometry.location.lng()
};
}));
});
},
select: function(event, ui) {

$input_area.val(ui.item.latitude + ‘,’ + ui.item.longitude );

var location = new window.google.maps.LatLng(ui.item.latitude, ui.item.longitude);

gmap.setCenter(location);
// Drop the Marker
setTimeout( function(){
marker.setValues({
position : location,
animation : window.google.maps.Animation.DROP
});
}, 1500);
}
});
}

autoCompleteAddress();
[/js]

Insert this function after `geocodeAddress` function (it’s in line: 1517). You also need to add jQuery UI Autocomplete script in your theme/plugin. Inserting `wp_enqueue_script( ‘jquery-ui-autocomplete’ );` to the right place will add jQuery UI Autocomplete script.

April 23, 2013 at 7:07 am 2751
noomia noomia

Hi Tareq !

Nice 🙂 ! Do you plan to add it in a future update ? Cause now if I add this snippet, it will be removed at next update ;).

Thanks 🙂 !

April 23, 2013 at 7:19 am 2754
Tareq Hasan Tareq Hasan

Yes, it’s already been added and will come in the next update.

If you like the plugin and support, I would love to have a testimonial from you 🙂

April 23, 2013 at 7:36 am 2757
noomia noomia

Sure I will 😉 !

Do you approximatively know when the next version will be released ? More than a week ?

Thanks 🙂 !

April 23, 2013 at 7:43 am 2758
Tareq Hasan Tareq Hasan

I am not sure about the date, there isn’t any feature that you need to wait for 😉

May 7, 2013 at 3:43 pm 3306
amelaunsworth amelaunsworth

hi there,
is the Google map only for coordinates? and you need another text field to enter and save one’s address?

Or is there a way that the Google maps retrieves coordinates and saves the address as well?
because right now i had to add two fields for customer’s to enter their address. one to save their address to their profile and one to save coordinates for google map.

form: http://www.godurhamregion.com/register-form/

is this how it’s supposed to be?

May 7, 2013 at 4:06 pm 3308
Tareq Hasan Tareq Hasan

Right now, the map field only saves the co-ordinates, it doesn’t include the address field. But also, we can save the address field from that field perhaps. Using this code should do this (paste in themes functions.php).

[php]
function wpufe_inesrt_address( $user_id ) {
if ( isset( $_POST[‘find-address’] ) ) {
update_user_meta( $user_id, ‘address’, $_POST[‘find-address’] );
}
}

add_action( ‘wpuf_after_register’, ‘wpufe_inesrt_address’ );
[/php]

May 7, 2013 at 4:39 pm 3311
amelaunsworth amelaunsworth

Form:
http://www.godurhamregion.com/register-form/

Listing:
http://www.godurhamregion.com/item/test-3/

hi there, thank you for responding so quickly!! i removed the extra address field and left only the google maps (also added code to functions.asp page) and it still only saves gps coordinates. no actually address. can you assist further?

also, the image uploaded is not showing up. i am using the Image Upload function. meta key is image. not sure if you can help me with this.

thanks for your help!!! really appreciate it.

May 7, 2013 at 8:36 pm 3323
Tareq Hasan Tareq Hasan

I think it stores the address, you can’t see it in the form because it’s not saving on a form field. It’s saving in a user meta field. You can check it in your database may be.

Images not showing up where? In the post? Make sure you’ve checked the settings “Custom Fields in post” from plugin settings.

May 7, 2013 at 9:17 pm 3326
amelaunsworth amelaunsworth

hey buddy,
i’ve tried everything! i’m not a programmer, so i’m struggling.

i still can’t get the image to show up on my listing page using the image upload custom field. i tried all meta keys: image, upload_image, images. i even added the file upload field. can you help?

the code you sent for functions.asp still doesn’t work for me. i have to use a custom field called Address. it’s supposed to show up beside the description like this page: http://www.godurhamregion.com/item/sport-chek-harmony/

been at this all! i’m not a programmer…if you can help me, i would really appreciate it. these are the last two items i need to do and then i can launch.

http://www.godurhamregion.com/register-form/

http://www.godurhamregion.com/item/spa-sedona-2/

May 7, 2013 at 9:21 pm 3327
Tareq Hasan Tareq Hasan

Is that a post creation form or user registration form? I gave you the code for user registration form.

May 7, 2013 at 9:35 pm 3328
amelaunsworth amelaunsworth

it’s a post creation form

Viewing 15 Posts - 1 through 15 (of 27 total)