我有5个字段的HTML表单。谷歌地图网关超时与PHP
1)地址2)城市3)州4)国家5)邮政编码。
输入此字段值后,显示Google地图。
谷歌地图代码:
<?php
$add = urlencode($_POST['address']);
$city = urlencode($_POST['city']);
$state = urlencode($_POST['state']);
$country = urlencode($_POST['country']);
$zip = $_POST['zip'];
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode
/json?address='.$add.',+'.$city.',+'.$state.',+'.$country.'&sensor=false');
$output= json_decode($geocode); //Store values in variable
if($output->status == 'OK'){ // Check if address is available or not
echo "<br/>";
echo "Latitude : ".$lat = $output->results[0]->geometry->location->lat; //Returns Latitude
echo "<br/>";
echo "Longitude : ".$long = $output->results[0]->geometry->location->lng; // Returns Longitude
?>
<script type="text/javascript">
$(document).ready(function() {
// Define the latitude and longitude positions
var latitude = parseFloat("<?php echo $lat; ?>"); // Latitude get from above variable
var longitude = parseFloat("<?php echo $long; ?>"); // Longitude from same
var latlngPos = new google.maps.LatLng(latitude, longitude);
// Set up options for the Google map
var myOptions = {
zoom: 10,
center: latlngPos,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControlOptions: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE
}
};
// Define the map
map = new google.maps.Map(document.getElementById("map"), myOptions);
// Add the marker
var marker = new google.maps.Marker({
position: latlngPos,
map: map,
title: "test"
});
});
</script>
<div id="map" style="width:450px;height:350px; margin-top:10px;"></div> // Div in which
Google Map will show
<?php
}
?>
但在提交进程页之后它的显示以下错误:
Warning: file_get_contents(http://maps.google.com/maps/api/geocode
/json?address=,+Dhaka,+,+Bangladesh&sensor=false): failed to open stream: HTTP request failed! HTTP/1.0 504 Gateway Timeout in D:\Software\Installed\xampp\htdocs\Classified-website \lat-long.php on line 19Notice: Trying to get property of non-object in D:\Software\Installed\xampp\htdocs\Classified- website\lat-long.php on line 23
什么是我的代码错了吗?有人帮我吗?
谢谢。
没有帮助回答!
它看起来不像你的代码有什么问题。更多与网关:*“HTTP请求失败!HTTP/1.0 504网关超时”* – hakre
那么,@hakre所以需要做什么来解决它? – Alex
您是否联系了网关的运营商并向他们报告了问题?因为我会先问那里,而不是我。我没有为你运行那个网关,你知道吗? ;) – hakre