0
角度js google map apiを使用してクリックイベントを作成します。角度を使ってGoogleマップのマーカークリックイベント
マーカーをクリックすると、情報ウィンドウを開かずに関数を呼び出すことができます。
どうすればいいですか?
$scope.map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: { lat: parseFloat(Center_lat) , lng: parseFloat(center_lang) }
});
$scope.infowindow = new google.maps.InfoWindow({
// content: ''
});
angular.forEach($scope.panoramas, function(value, index) {
var latLang = $scope.panoramas[index].project_latLng ;
// console.log(latLang)
var LatLngArr = latLang.split(",");
var lat = LatLngArr[0];
var lang = LatLngArr[1];
console.log("lat " ,lat);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(parseFloat(lat), parseFloat(lang)),
map: $scope.map,
icon:"images/map-circle.png",
draggable:true,
label: {
color: 'black',
fontWeight: 'bold',
text: $scope.panoramas[index].panoId,
},
title: $scope.panoramas[index].panoId
});
var content = '<a ng-click="ShowCenterPano(' + index + ')" class="btn btn-default">View details</a>';
var compiledContent = $compile(content)($scope)
google.maps.event.addListener(marker, 'click', (function(marker, content, scope) {
return function() {
scope.infowindow.setContent(content);
scope.infowindow.open(scope.map, marker);
};
})(marker, compiledContent[0], $scope));
$scope.ShowCenterPano = function(index) {
// alert(JSON.stringify($scope.panoramas[index]));
}
ここで情報ウィンドウが開きます。情報ウィンドウを削除してShowCenterPano()関数を直接呼び出すにはどうしたらいいですか?
その私に、このエラーを与えるこの行を開くためにそれを頼むので、情報ウィンドウが開いている理由は、 Uncaught ReferenceError:ShowCenterPanoが定義されていません – upendtu
あなたは$ scope.ShowCenterPano(index)を呼び出していますか?インデックスは、関数で使用できる変数である必要があります。 – Nat
もう1つのヒントは、関数名を小文字で始めることです。したがって、showCenterPanoにする必要があります。 – Nat