Skip Navigation

[Resolved] Split: change placeholder text for Maps fields on a Post Form? – map address field limit to specific country not working

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 11 months ago.

Assisted by: Minesh.

Author
Posts
#2676293

Hi Minesh

Apologies if there have been any misunderstandings. I understand that you didn't ADD the setTimeout( delayed, 2000 ); however in your reply

https://toolset.com/forums/topic/customise-the-placeholder-text-for-maps-fields-on-a-post-form/page/2/#post-2675479

you did add code to an existing function where it was already included in the "Post Form - New Job Ad".

I assumed that copying and pasting the same code to the Edit form would work. However, on further testing, with or without your code present for the placeholder text (which seems to work correctly, thank you!!)), it would appear that the limiting of the Google autocomplete is the thing not working reliably. It looks like if you edit the Job Ad and then go straight into the Address location field, then enter "Paris", that the autocomplete suggestions are not limiting to Germany as they should.

However, it I delete out "Paris" from the address location field, click somewhere else in the Edit form, and then go back into the address location field and enter "Paris", only German locations are displayed as required.

So it would appear that the address limiting isn't working reliably until the 2nd click in the address location field.

I created a video to show you what I mean.
hidden link

Kind regards
Simon

#2676494

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

To you edit form I've added the JS code as given under:

jQuery(document).on( 'input', '.js-toolset-google-map-geocomplete-added', function(e){
	e.preventDefault();
	var map = jQuery(this).closest('.js-toolset-google-map-container').find('.js-toolset-google-map-preview:eq(0)');
	var input = document.getElementById('cred_form_931_1_1_family-approximate-location');
	var options = {
		//types: ['(cities)'],
		componentRestrictions: {country: 'DE'}, 'map': map
	};
	autocomplete = new google.maps.places.Autocomplete(input, options);
});

Can you please confirm now it works as expected. Before the above code was added on click event which we change to on "input" event.

#2676503
Screenshot 2023-12-28 at 13.35.38.jpeg

Hi Minesh

That works almost 100% of the time. 😉

The only "gap" I can see, is when you select all the content and paste in a value, eg "Paris", non-German addresses are still suggested:
See video: hidden link and screenshots from mobile.

However, apparently pressing keys on the keyboard, including backspace key, also on mobile, or typing in an address will immediately limit the addresses to Germany. You can see at the end of my video, that as I soon as I press Command-Shift-5 to stop recording the video, that the field immediately stops suggesting non-German addresses. Bit strange that a Command-V for paste command doesn't do the same job.

Additionally, a non-German address cannot be saved, due to error checking, so it should be impossible for the users to save a non-German address.

Unless you know some easy way to prevent non-German addresses EVER being suggested for the field, then I think we can live with this.

Thanks and regards
Simon

#2676510

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Unless you know some easy way to prevent non-German addresses EVER being suggested for the field, then I think we can live with this.
===>
I'm not sure how to prevent the google autocomplete suggestion for non-german address I do not know much. Its a custom code and if you need help I suggest you should get in touch with Javascript/jQuery pro who can help you in this matter further.

As you know what is the code and what is the culprit that might help you take this issue in front of them. I help best that I can but I do not have other other solution to offer as of now.

#2676511

HI Minesh

That's fine. Like I said, it was just in case you knew a quick solution. I think the current solution is robust enough and it is not worth spending more time on this ticket.

Thanks and kind regards
Simon