【问题标题】:Unable to navigate to a new screen on marker click in AngularJS在AngularJS中单击标记时无法导航到新屏幕
【发布时间】:2018-07-17 11:34:57
【问题描述】:

我在 angularJS 中使用谷歌地图,而且我是 AngularJS 的新手。 我正在尝试使用 $location 单击标记导航到新屏幕,但我无法做到这一点。获取路径未定义错误。有人可以帮忙吗?

var myapp = angular.module("googleApp", ['ngRoute']);

myapp.controller("initMap",initMap('$location','$path'))

函数 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");

    });

【问题讨论】:

    标签: javascript html angularjs google-maps google-maps-markers


    【解决方案1】:

    而不是 $location.path("\");试试这个 $scope.showNextPage("文件名"); 如果文件在同一个文件夹中 否则 $scope.showNextPage("path");

    【讨论】:

    • 它的意思是“无法读取未定义的属性'showNextPage'”。
    猜你喜欢
    • 2019-09-25
    • 1970-01-01
    • 2020-02-08
    • 2020-01-01
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    相关资源
    最近更新 更多