-
-
Save sanjaygeeky/eb782abb25dd09e4f1d971cde899e0a5 to your computer and use it in GitHub Desktop.
Fix for Google AutoComplete Places Javascript API on iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var autoElm = document.getElementById('elm-name'); | |
| autocomplete = new google.maps.places.Autocomplete(autoElm); | |
| google.maps.event.addListener(autocomplete, 'place_changed', function () { | |
| var place = autocomplete.getPlace(); | |
| if (!place.geometry) { | |
| return; | |
| } | |
| instance.setCenter(place.geometry.location); | |
| instance.setZoom(19); | |
| autoElm.value = ''; | |
| }); | |
| // need to stop prop of the touchend event | |
| if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) { | |
| setTimeout(function() { | |
| var container = document.getElementsByClassName('pac-container')[0]; | |
| container.addEventListener('touchend', function(e) { | |
| e.stopImmediatePropagation(); | |
| }); | |
| }, 500); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment