0
我想運行以下地理位置代碼,但下面的代碼返回undefined。任何人都可以指導我請地理位置代碼返回undefined
當我打電話例如
警報(verifylocation())的功能;
它返回未定義。我想用這個表單驗證
<script src="//maps.googleapis.com/maps/api/js?key=<?=$google_api_key?>&sensor=false" type="text/javascript"></script>
<script language="javascript">
var geocoder, location1, location2, radius_verified;
geocoder = new google.maps.Geocoder();
radius_verified = - 1;
var Zone1, Zone1_enabled;
var Zone2, Zone2_enabled;
var Zone3, Zone3_enabled;
window.verifylocation = function() {
\t var restaurant_location = '<?= $objRestaurant->rest_address . ", " . $objRestaurant->rest_city . ", " . $objRestaurant->rest_state; ?>';
\t var customer_location = $("#customer_address").val() + " , " + $("#customer_city").val() + " , " + $("#customer_state").val();
\t
var radius = '<?= $objRestaurant->delivery_radius ?>';
\t
geocoder.geocode({'address': restaurant_location}, function(results, status) {
\t \t // Here is my Code but before my code run it returns undefined.
});
};
什麼變量未定義? – Griffith
當我調用函數例如alert(verifylocation()) –
你沒有返回函數中的任何值。你想要返回什麼? – Griffith