如何打开和关闭谷歌与地图自动完成? [英] How to toggle the google-maps autocomplete on and off?

查看:470
本文介绍了如何打开和关闭谷歌与地图自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实例谷歌地图API自动完成输入(3级),像这样:

I'm instantiating an autocomplete input for Google Maps API (level 3), like so:

var input = document.getElementById('szukanyAdres');
autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);

如何在运行时打开自动完成功能打开和关闭?

How to turn the autocompletion functionality on and off at runtime?

推荐答案

有相关的自动完成两个元素

There are two elements related to the autocomplete


  1. 输入元素

  2. 包含列表的条目股利。此格将附加到体内,并具有一流PAC-容器

你可以这样做什么:显示或隐藏通过修改它们的显示风格的两种元素

So what you can do: show or hide both elements by modifying their display-style.

当它无法隐藏输入你可能会与输入的克隆更换输入,这将删除自动完成的功能。

When it's not possible to hide the input you may replace the input with a clone of the input, this will remove the autocomplete-functionality.

inputObject.parentNode.replaceChild(inputObject.cloneNode(true),input);

要恢复自动完成你想做的事做了。

To restore the autocomplete do again what you want to do.

这篇关于如何打开和关闭谷歌与地图自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆