Javascript 回调函数gmap

Javascript 回调函数gmap,javascript,google-maps,Javascript,Google Maps,我对Gmpaps编程中的回调函数有问题。 如果在用户从网页菜单中选择的特定距离范围内,我会在地图上插入一些兴趣点。 我的问题是,是否可以在回调函数中添加一些javascript代码,例如用弹出消息提醒用户等等 function callback(response, status) { if (status != google.maps.DistanceMatrixStatus.OK) { alert('E

我对Gmpaps编程中的回调函数有问题。 如果在用户从网页菜单中选择的特定距离范围内,我会在地图上插入一些兴趣点。 我的问题是,是否可以在回调函数中添加一些javascript代码,例如用弹出消息提醒用户等等

 function callback(response, status) {             
              if (status != google.maps.DistanceMatrixStatus.OK) {
                  alert('Error was: ' + status);
              } else {
                var origins = response.originAddresses;
                var destinations = response.destinationAddresses;
                var icon_2 = mapinfo[address_index_2-1][6];
                var results = response.rows[0].elements;
                     //alert(results[0].distance.value+" <= " +distance_selected);    
                      if(results[0].distance.value <= distance_selected){

                       // HERE I WOULD TO ADD SOME CODE e.g. AN ALERT 

                        geocoder.geocode({'address': mapinfo[address_index_2-1][1]+" "+mapinfo[address_index_2-1][2]+" "+mapinfo[address_index_2-1][3]+" "+mapinfo[address_index_2-1][4]}, 
                        function(results, status) {
                         if (status == google.maps.GeocoderStatus.OK) {
                              bounds.extend(results[0].geometry.location);
                              map.fitBounds(bounds);
                              var marker = new google.maps.Marker({
                              map: map,
                              position: results[0].geometry.location,
                              icon: icon_2
                            });
                              map.setZoom(15);
                              map.setCenter(marker.getPosition());
                              google.maps.event.addListener( marker, 'mouseover', function() {
                                            // Setting the content of the InfoWindow
                                            var filo_content = '<div id="info_map"><h3>' + f_title + '</h3></h5><a href="'+ f_link +'"><h5>Leggi...</h5></a>' + '</div>';                                                
                                            infowindow.setContent(filo_content);                                             
                                            infowindow.open(map, marker);
                                            }); 

                              markersArray.push(marker);   
                          } 
                          else {
                            alert("Geocode was not successful for the following reason: "
                              + status);
                          } // chiusura else

                        });

                      }  //chiusura if controllo distanza

                    }

              } // chiusura callback

为什么不呢,这是回调函数的唯一用途,而且您已经收到了警报!到底是什么问题?是的,但警报不起作用:例如,如果我在回调函数中设置了一个全局变量,则结果otuside是未定义的…最好使用回调函数中设置的任何变量,即函数本身。它们在您发现它运行之前是无效的。非常感谢您的建议。我已经解决了。。问题是我调用了另一个同名回调函数的else if。。。