1

データがmySqlバックエンドから来ており、エンコードされた文字列として保存しているGoogleマップのセットアップがあります。マップにデータを正しく表示できますが、外部リンクを提供できません。

    for (x = 0; x < stringArray.length; x = x + 1)
    {
        var addressDetails = [];
        var marker;
        //Separate each field
        addressDetails = stringArray[x].split("&&&");
        //Load the lat, long data
        var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
        //Create a new marker and info window
        var y = x+1;
        marker = new google.maps.Marker({
            map: map,
            position: lat,
            content: addressDetails[0],
            icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+y+'|FF0000|000000'
        });
        //Pushing the markers into an array so that it's easier to manage them
        markersArray.push(marker);

        google.maps.event.addListener( marker, 'click', function () {
            closeInfos();
            var info = new google.maps.InfoWindow({content: this.content});
            //On click the map will load the info window
            info.open(map,this);
            infos[0]=info;
        });
       //Extends the boundaries of the map to include this new location
       bounds.extend(lat);
    }
    //Takes all the lat, longs in the bounds variable and autosizes the map
    map.fitBounds(bounds);

そして、このコードは外部クリック用です。

    function myclick(i) {
      google.maps.event.trigger(markersArray[i], "click");
    }

私が得ているエラーは次のとおりです。「Uncaught ReferenceError: myclick is not defined」

私がどこを間違えたのか教えてください。

ありがとう、

4

1 に答える 1