我在angularJS中使用谷歌地图,我是AngularJS的新手。 我试图使用$ location点击标记导航到新屏幕,但我无法做到。获取路径未定义错误。可以帮助一些人。
var myapp = angular.module("googleApp", ['ngRoute']);
myapp.controller( “initMap”,initMap( '$位置', '$路径'))
function initMap($ location,$ path){ var loaction1 = {lat:17.3850,lng:78.4867};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5,
center: loaction2
});
var marker1 = new google.maps.Marker({
position: loaction1,
map: map
});
var infowindow = new google.maps.InfoWindow({
content: '<p>Marker Location:' + marker1.getPosition() + '</p>'
});
google.maps.event.addListener(marker1, 'click', function() {
infowindow.open(map, marker1);
});
var selectedLocation = [{"lat":0,"long":0}];
marker1.addListener('click', function() {
map.setZoom(7);
map.setCenter(marker1.getPosition());
// console.log("Click registered" + marker1.getPosition());
selectedLocation[0].lat = marker1.getPosition().lat();
selectedLocation[0].long = marker1.getPosition().lng();
console.log("Latitude is " + selectedLocation[0].lat + "Longitude is " + selectedLocation[0].long);
var check = false;
$location.path("/valuePage.html");
});
答案 0 :(得分:0)
而不是$ location.path(“\”);试试这个 $ scope.showNextPage(“文件名”); 如果文件在同一文件夹中 否则$ scope.showNextPage(“path”);