google maps custom local search / search control

孤人 提交于 2019-12-07 11:02:30

问题


I have two questions about google maps local search. Here is my code:

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. How can I avoid creating google's markers and result list? -> I want to display only my own markers...
  2. How can I submit the "google search bar" programmatically in JavaScript?


Ok, I try to solve it in another way. At first I created a google search form and a local searcher (see code below). But an execution is bringing no results... Any ideas?

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);
}

来源:https://stackoverflow.com/questions/3386841/google-maps-custom-local-search-search-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!