0

在这里阅读了很多帖子(不幸的是,其中大多数都与 API v2 相关)并且仍然没有任何线索之后,我的谦虚请求:

我正在尝试从两个地理编码器调用中获取 LatLng 数据:

                    function geocoderMarkerA(fromValue) {
                        return geocoder.geocode( { 'address': fromValue}, function(results, status) {
                          if (status == google.maps.GeocoderStatus.OK) {
                            var markerA = new google.maps.Marker({
                                map: map, 
                                position: results[0].geometry.location,
                                icon: 'red_MarkerA.png'
                            });
                            return results[0].geometry.location;
                          } else {
                            Ti.API.info("Geocode was not successful for the following reason: " + status);
                          }

                        });
                    }

                    function geocoderMarkerB(toValue) {
                        return geocoder.geocode( { 'address': toValue}, function(results, status) {
                          if (status == google.maps.GeocoderStatus.OK) {
                            var markerA = new google.maps.Marker({
                                map: map, 
                                position: results[0].geometry.location,
                                icon: 'green_MarkerB.png'
                            });
                            return results[0].geometry.location;
                          } else {
                            Ti.API.info("Geocode was not successful for the following reason: " + status);
                          }

                        });
                    }

我尝试使用 $.when 但我仍然无法获得两个返回的数据。我只想将两个结果作为两个变量或一个数组。预先表示衷心的感谢!

4

0 回答 0