Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌地图搜索我的标记_Javascript_Google Maps_Search_Google Maps Api 3 - Fatal编程技术网

Javascript 谷歌地图搜索我的标记

Javascript 谷歌地图搜索我的标记,javascript,google-maps,search,google-maps-api-3,Javascript,Google Maps,Search,Google Maps Api 3,所以我放置了两个标记(将会更多),并且在我的地图上方有一个搜索栏。我想能够使用这个搜索栏搜索关键字,并有这些关键字的标记地图中心。我假设我会做一些事情,将自定义标记添加到作为关键字的标记中,但我不确定这将如何工作,因为我正在for循环中创建标记。我真的不知道如何开始实施这样的东西。但以下是我的代码: var locations = [ ['Passage Island', 49.343085, -123.305938, 'http://tylerkohlhaas.gith

所以我放置了两个标记(将会更多),并且在我的地图上方有一个搜索栏。我想能够使用这个搜索栏搜索关键字,并有这些关键字的标记地图中心。我假设我会做一些事情,将自定义标记添加到作为关键字的标记中,但我不确定这将如何工作,因为我正在for循环中创建标记。我真的不知道如何开始实施这样的东西。但以下是我的代码:

var locations = [
            ['Passage Island', 49.343085, -123.305938, 'http://tylerkohlhaas.github.io/waterscout/passage.html'],
            ['Point Atkinson', 49.329925, -123.264994, 'http://tylerkohlhaas.github.io/waterscout/patkinson.html']
        ];
var i;

        for(i=0; i < locations.length; i++)
        {
            var markers = new google.maps.Marker({
                position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
                map: map,
                clickable: true,
                url: locations[i][3],
                zIndex: 1
            });

            google.maps.event.addListener(markers, 'click', function(){
                window.location.href = this.url; 
            });
        }
var位置=[
[“通道岛”,49.343085,-123.305938,'http://tylerkohlhaas.github.io/waterscout/passage.html'],
[阿特金森角,49.329925,-123.264994,'http://tylerkohlhaas.github.io/waterscout/patkinson.html']
];
var i;
对于(i=0;i
我的搜索栏的html非常基本:

<form>
            <input type="search", class="SearchBar", placeholder="Search for an area", name="Search", target="_self", size=50>

任何帮助或建议都将不胜感激!
您可以执行以下操作:

var locations = [
        ['Passage Island', 49.343085, -123.305938, 'http://tylerkohlhaas.github.io/waterscout/passage.html',['tag1','tag2']],
        ['Point Atkinson', 49.329925, -123.264994, 'http://tylerkohlhaas.github.io/waterscout/patkinson.html',['tag3','tag4']]
    ];
    var i;
    var markerArray=[];

    for(i=0; i < locations.length; i++)
    {
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
            map: map,
            clickable: true,
            url: locations[i][3],
            zIndex: 1,
            searchTag: locations[i][4],
            searchName: locations[i][0]
        });

        google.maps.event.addListener(marker, 'click', function(){
            window.location.href = this.url; 
        });
        markerArray.push(marker);
    }
var位置=[
[“通道岛”,49.343085,-123.305938,'http://tylerkohlhaas.github.io/waterscout/passage.html“,['tag1','tag2']],
[阿特金森角,49.329925,-123.264994,'http://tylerkohlhaas.github.io/waterscout/patkinson.html“,['tag3','tag4']]
];
var i;
var-markerary=[];
对于(i=0;i
在搜索功能中,您将使用Markerary中的searchTag和searchName字段。也就是说,如果您想查看第一个标记,可以使用类似于
markerary[0]['searchTag']