4

我有两个关于谷歌地图本地搜索的问题。这是我的代码:

var options = {
    onSearchCompleteCallback:function(searcher) {
        // content of onSearchCompleteCallback function
        // creates markers and applies addresses to a result list
        // at this point code isn't necessary, because this function already works
    }
};
localSearch = new google.maps.LocalSearch(options);
map.addControl(localSearch);
  1. 如何避免创建 Google 的标记和结果列表?-> 我只想显示我自己的标记...
  2. 如何在 JavaScript 中以编程方式提交“谷歌搜索栏”?


好的,我尝试用另一种方式解决它。起初我创建了一个谷歌搜索表单和一个本地搜索器(见下面的代码)。但是执行没有带来任何结果......有什么想法吗?

var SearchForm = null;
var Searcher = null;

function GetSearchResult() {
}
            
function RunMapSearch(searchForm) {
    Searcher.setCenterPoint(center);
    Searcher.execute(searchForm.input.value);
}
            
function CreateMapSearch() {
    // Creating search form
    SearchForm = new google.search.SearchForm(false, document.getElementById("SearchBar"));
    SearchForm.setOnSubmitCallback(this, RunMapSearch);
                
    // Creating searcher for local search
    Searcher = new google.search.LocalSearch();
    Searcher.setCenterPoint(center);
    Searcher.setSearchCompleteCallback(null, GetSearchResult);
}
4

0 回答 0