私はVisual Studio '15でコードナビのタブテンプレートプロジェクトを実行しようとしています。私は単に私のタブmap.htmlにGoogleマップをロードしようとしているが、私は次のエラーを取得しています:ここGoogleマップをイオン化して統合する
TypeError: $scope.init is not a function
at new <anonymous> (http://localhost:4400/js/controllers.js:22:12)
at Object.instantiate (http://localhost:4400/lib/ionic/js/ionic.bundle.js:18010:14)
at $controller (http://localhost:4400/lib/ionic/js/ionic.bundle.js:23412:28)
at self.appendViewElement (http://localhost:4400/lib/ionic/js/ionic.bundle.js:59900:24)
at Object.render (http://localhost:4400/lib/ionic/js/ionic.bundle.js:57893:41)
at Object.init (http://localhost:4400/lib/ionic/js/ionic.bundle.js:57813:20)
at self.render (http://localhost:4400/lib/ionic/js/ionic.bundle.js:59759:14)
at self.register (http://localhost:4400/lib/ionic/js/ionic.bundle.js:59717:10)
at updateView (http://localhost:4400/lib/ionic/js/ionic.bundle.js:65398:23)
at http://localhost:4400/lib/ionic/js/ionic.bundle.js:65375:11
は私のタブmap.htmlです:
<ion-view view-title="Map">
<ion-content class="padding">
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingIcon="arrow-dropdown"
pullingText="Pull to refresh"
refreshingSpinner="circles"
refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>
<h2 align="center">Map</h2>
<div id="map" data-tap-disabled="true"></div>
</ion-content>
<ion-footer-bar class="bar-dark">
<a ng-click="centerOnMe()" class="button button-icon icon ion-navigate">Find Me</a>
</ion-footer-bar>
</ion-view>
そして、私のcontroller.jsをこのコントローラは、JSファイルの真ん中にあるので、それの終わり
.controller('MapCtrl', function ($scope, $ionicLoading, $compile) {
$scope.init() = function() {
console.log("Is this thing on?");
var myLatlng = new google.maps.LatLng(35.182217, -83.381418);
var mapOptions = {
center: myLatlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
mapOptions);
//Marker + infowindow + angularjs compiled ng-click
var contentString = "<div><a ng-click='clickTest()'>Click me!</a></div>";
var compiled = $compile(contentString)($scope);
var infowindow = new google.maps.InfoWindow({
content: compiled[0]
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Franklin, NC'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
$scope.map = map;
}
//google.maps.event.addDomListener(window, 'load', initialize);
$scope.centerOnMe = function() {
if (!$scope.map) {
return;
}
$scope.loading = $ionicLoading.show({
content: 'Getting current location...',
showBackdrop: false
});
navigator.geolocation.getCurrentPosition(function (pos) {
$scope.map.setCenter(new google.maps.LatLng(pos.coords.latitude,
pos.coords.longitude));
$scope.loading.hide();
}, function(error) {
alert('Unable to get location: ' + error.message);
});
};
$scope.clickTest = function() {
alert('Example of infowindow with ng-click')
};
})
応答のおかげで、私はまだ同じエラーが発生しています! :( – user3763334