Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS和Google Maps API V3无法对循环中的地址进行地理编码_Javascript_Angularjs_Google Maps Api 3_For Loop - Fatal编程技术网

Javascript AngularJS和Google Maps API V3无法对循环中的地址进行地理编码

Javascript AngularJS和Google Maps API V3无法对循环中的地址进行地理编码,javascript,angularjs,google-maps-api-3,for-loop,Javascript,Angularjs,Google Maps Api 3,For Loop,我正在尝试为AngularJS范围内的每一个标记进行地理编码,可以使用$scope.locations获取这些标记 我一直收到以下错误类型错误:无法调用未定义的方法“geocode” 我设置了var geocoder、geocode、geocode_结果;在我的档案顶部 在一个示例中,$scope.location在I console.log时包含以下数据 $$hashKey: "009" desc: "Closest test" gps: "ab42 2dl" title: "A pl

我正在尝试为AngularJS范围内的每一个标记进行地理编码,可以使用$scope.locations获取这些标记

我一直收到以下错误类型错误:无法调用未定义的方法“geocode”

我设置了var geocoder、geocode、geocode_结果;在我的档案顶部

在一个示例中,$scope.location在I console.log时包含以下数据

$$hashKey: "009"    
desc: "Closest test"
gps: "ab42 2dl"
title: "A place"
下面是我用来尝试运行位置循环的代码

$scope.plotmarkers = function() {
    console.log($scope);
//          var temp_addresses = document.getElementById("gps").value.split("\n");
            var temp_addresses = $scope.locations;
            console.log(temp_addresses);

            for(var i=0;i<temp_addresses.length;i++){
        //      addresses.push(temp_addresses[i]);
console.log(temp_addresses[i].gps);
                geocoder.geocode( { 'address': temp_addresses[i].gps}, function(response, status) {
                    geocode_results[i] = new Array();
                    geocode_results[i]['status'] = status;
console.log('2')
                    if (!response || status != google.maps.GeocoderStatus.OK) {
                        if(status == google.maps.GeocoderStatus.ZERO_RESULTS){
                            geocode_results[i]['lat'] = 0;
                            geocode_results[i]['lng'] = 0;
                        } else {
                            timeouts++;
                            if(timeouts>6){
                                alert("You have reached the limit of of requests that you can make to google from this IP address in one day.");
                            }
                        }
                    } else {
                        timeouts = 0;
                        top_location = response[0];
                        var lat = Math.round(top_location.geometry.location.lat() * 1000000)/1000000;
                        var lng = Math.round(top_location.geometry.location.lng() * 1000000)/1000000;
                        geocode_results[i]['lat'] = lat;
                        geocode_results[i]['lng'] = lng;
                        geocode_results[i]['l_type'] = top_location.geometry.location_type;
                        marker = new google.maps.Marker({
                            icon: mapIcon,
                            position: new google.maps.LatLng(lat,lng),
                            map: map
                        });
                        arrayLocation.push(top_location.address_components[0].long_name);
        //              console.log(top_location.address_components[0].long_name);
                    }
                });
            }

    };
我失踪了

var geocoder = new google.maps.Geocoder();

你是如何初始化地理编码器的?在调用plotmarkers中的地理代码时,If看起来似乎未定义。