- Posts: 19
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Autocompleted Address breakdown into multiple fields
- dirk01
- Offline
- New Member
Less
More
5 years 7 months ago #173264
by dirk01
Replied by dirk01 on topic Autocompleted Address breakdown into multiple fields
Tpartner,
Thank you for the quick respons.
It works for me too!
It saved my day and a couple of days work.
It is a great way of questioning someone's displacements.
Dirk
Thank you for the quick respons.
It works for me too!
It saved my day and a couple of days work.
It is a great way of questioning someone's displacements.
Dirk
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
5 years 7 months ago #173265
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Autocompleted Address breakdown into multiple fields
Any idea why it works with AJAX on in the other displaymode? The different displaymodes alone are a nice source of bugs.tpartner wrote: The attached sample survey works for me in group-by-group if I disable AJAX mode in the theme options.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
5 years 7 months ago #173267
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autocompleted Address breakdown into multiple fields
I think that in "all-in-one" mode, the AJAX is not used as everything is loaded as a single page.
I did not bother to debug the problem when AJAX is used (I rarely use it).
I did not bother to debug the problem when AJAX is used (I rarely use it).
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- davidg1982
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
4 years 7 months ago #188683
by davidg1982
Replied by davidg1982 on topic Autocompleted Address breakdown into multiple fields
How do I add Lat and Long to the script?
I am not sure how to do that.
I am not sure how to do that.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 7 months ago - 4 years 7 months ago #188687
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autocompleted Address breakdown into multiple fields
You can use the place.geometry.location.lat() and place.geometry.location.lng() functions:
Sample survey attached:
Code:
<script> function init() { $('#displayCounty').hide(); // Disable the partial-address inputs $('#question{QID} input:text:gt(0)').prop('readonly', true); // Un-comment below to hide the partial-address inputs //$('#question{QID} input:text:gt(0)').hide(); var input = document.getElementById('answer{SID}X{GID}X{QID}SQ001'); var autocomplete = new google.maps.places.Autocomplete(input); autocomplete.addListener('place_changed', function() { var place = autocomplete.getPlace(); var components = place.address_components; if (components) { for (var i = 0, l = components.length; i < l; i++) { var component = components[i]; if (component.types && component.types.indexOf('street_number') !== -1) { $('#answer{SID}X{GID}X{QID}SQ002').val(component.long_name); } if (component.types && component.types.indexOf('route') !== -1) { $('#answer{SID}X{GID}X{QID}SQ003').val(component.long_name); } if (component.types && component.types.indexOf('locality') !== -1) { $('#answer{SID}X{GID}X{QID}SQ004').val(component.long_name); } if (component.types && component.types.indexOf('administrative_area_level_2') !== -1) { $('#displayCounty').text('County: ' + component.long_name); $('#displayCounty').show(); $('#answer{SID}X{GID}X{QID}SQ005').val(component.long_name); } if (component.types && component.types.indexOf('administrative_area_level_1') !== -1) { $('#answer{SID}X{GID}X{QID}SQ006').val(component.long_name); } if (component.types && component.types.indexOf('country') !== -1) { $('#answer{SID}X{GID}X{QID}SQ007').val(component.long_name); } if (component.types && component.types.indexOf('postal_code') !== -1) { $('#answer{SID}X{GID}X{QID}SQ008').val(component.long_name); } $('#answer{SID}X{GID}X{QID}SQ009').val(place.geometry.location.lat(place.address_components.formatted_address)); $('#answer{SID}X{GID}X{QID}SQ010').val(place.geometry.location.lng(place.address_components.formatted_address)); } } }); } google.maps.event.addDomListener(window, 'load', init); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 4 years 7 months ago by tpartner.
The following user(s) said Thank You: davidg1982
The topic has been locked.