I'm instantiating a google maps Autocomplete box, as such:
autocomplete = new google.maps.places.Autocomplete(input, options);
Now, when a user begins typing and the list of suggestions appears, if a user simply presses Enter I want the number one prediction to be used as the search term.
For example, when a user searches: London, I want to pull out and send London, United Kingdom - simply by the user pressing Enter.
I can pull out that prediction using (with the latest V3.11):
autocomplete.gm_accessors_.place.Gc.predictions[0].wg
However, this obviously relies on the "compiled" object names, such as Gc and wg which will change as Google updates their codebase.
What is the correct way of doing this? Is it supported by the Autocomplete API?
Notice
Please star this issue on Google to get a solution:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=4945
there is no correct way when using places.Autocomplete, it's not implemented so far.
What you can do: the API creates the dropdown, a div with className "pac-container", and within that div for each prediction a div with the className "pac-item", you may use the text of the first .pac-item as value for the input.
A correct way would be to request the Places Autocomplete Service , but then you need to create the dropdown on your own.
Related
I am using the Google Maps API autocomplete. When I type in an address, I get suggestions. Valid results are bold, but invalid results are not. So, I might get an item in the drop down where the street name is bold, but the number is not:
So, if the users chooses 829 Wakely Terrace, I call getPlace and populate my address fields. But since its not a valid number, it looks like the number get stripped out. This is a confusing experience.
Can I force autocomplete to not do this?
Concersely, do I need some kind of "Did you mean this address?" functionality? Can anyone point me to an example of where this is handled well (Not for code, but UX purposes)?
I have a sort of answer. We were using the autocomplete widget from Google. Is till find it weird the whole bold/not bold thing, but if you use the AutocompleteService, you get the raw suggestions as JSON from Google. So, you need to do some more work to make the front end work, but you have a lot more control and con handle the situation as you see fit.
i want to add google map places suggestion API on typeform specific search text field.
is there possible anyway? because i can not find any way like via JavaScript to embed JavaScript code on typeform or 2nd i try where used this form it's also prevent to return iframe content.
My understanding is that you want to use a google places autocomplete field directly inside a typeform.
Is that right?
At the moment this is not possible on Typeform platform.
One workaround could be an intermediary step before the typeform, like a static HTML page where you present the user with such a field, and pass this data as hidden field to the Typeform.
If you want to restrict people within a certain location to answer your typeform here are some other alternatives:
using google tag manager ask for user's location, and redirect them out of the typeform if it does not fit your requirements
intermediary step to ask for user location (via the browser) and redirect them to the typeform or not
implement Typeform logic on a zipcode or country field.
Hope it helps,
You can also contact Typeform support directly if you have more precise questions.
I am using protractor with Jasmine framework for automating angular5 application. My developers have used API/created google maps dropdown as mentioned in the link
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
When user types on the address, google maps API is invoked and lists the places related to search, this will not populate/change any tags of developer tools HTML. So basically when user types address then it will populate the address dropdown and I want to select any address either through mouse/keyboard arrow key. When I am automating, I could reach till passing string to the address web element later it errors saying
No details available for input:'Mumbai'
with the popup displayed on the window. Any help is greatly appreciated.
I tried below code,
browser.actions().mouseMove(element(by.id('fromAddress-input')).sendKeys("Mumbai")).perform();
browser.actions().sendKeys(protractor.Key.ENTER).perform();
browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform();
browser.actions().sendKeys(protractor.Key.ENTER).perform();
First you need to switch to the Iframe that contains the elements you want, use this to change to the Iframe:
var driver = browser.driver;
var loc = by.tagName('iframe');
var el = driver.findElement(loc);
browser.switchTo().frame(el);
Create a function with this code and place after you load the page.
Then your code will work but remove the first enter, do this for example:
browser.actions().mouseMove(element(by.id('fromAddress-input')).sendKeys("Mumbai")).perform();
browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform();
browser.actions().sendKeys(protractor.Key.ENTER).perform();
change back to the main frame using this:
browser.switchTo().defaultContent();
I am using google map API to show our locations in a website
The problem:
I search something opening google.com and navigate to map, it is same as the locator on the website. It gives the same result.
When google is opened in local and navigate to map and do the same search, it will navigate to same place however the name is different. Please note it is not that name is in English and French that's the reason it is different. Basically this region on question is disputed over the countries.
Description:
When client opens google in his locale e.g. https://www.google.fr/ and navigates to google map he gets a different result, the name is different for the same place in google map as the place is in the border of 2 countries .
If you open by google.com it will show the widely accepted name whereas if you open google.xx and then open the same location the name will be different.
The locator by default is showing the global name in the website which the client does not want, he is asking for showing the name as displayed when opening from their region.
Is there a way I can set something like a data source or something to show google map based on some particular region.
Help will be appreciated.
Regards
Take a look here.
You can add an optional language parameter to the <script> tag when including the Maps API JavaScript code, specifying the language to use. For example, to display a Maps API application in Japanese, add &language=ja to the <script> tag.
Has anyone successfully accomplished this? I would like to initialize the autocomplete in a SlickGrid cell. I suspect that fashioning an autocomplete editor may be the way to go.
The cells don't have a DOM id but I have been able to use a getElementsByClassName('slick-cell l5 r5 cell-title active selected'), which is the cell that my Address column is in. I have seen where others have implemented an Autocomplete editor supplying a list but I can't seem to get either of these methods to work with the Google Maps Autocomplete code.
I'm fairly new to SlickGrid but have managed to accomplish many other things successfully except this one. Anyone pulled this off?