Javascript 谷歌地图Api

Javascript 谷歌地图Api,javascript,php,google-maps,Javascript,Php,Google Maps,我对Google Maps api集成表单自动完成有问题。 我已经实施了它,并正常工作,直到我试图限制由国家 <script> function initialize() { var defaultBounds = new google.maps.LatLngBounds( new google.maps.LatLng(40.802089, -124.163751) ); var origin_input = document.getElementById('location')

我对Google Maps api集成表单自动完成有问题。 我已经实施了它,并正常工作,直到我试图限制由国家

<script>
function initialize() {

var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(40.802089, -124.163751)
);

var origin_input = document.getElementById('location');
//var isocode = document.getElementById('ISOcountry').val()

var options = {
bounds: defaultBounds,
types: ['(cities)'],
language: '<?php echo $lang['dataLanguage']?>',
//componentRestrictions: {country: isocode }
};


var autocomplete_origin = new google.maps.places.Autocomplete(origin_input, options);    
}

google.maps.event.addDomListener(window, 'load', initialize);
从此处获取ISO国家/地区值:

你们知道吗

此外,我还想优化脚本,直接从此处附加的另一个脚本获取ISO代码:

$.post('libs/jsonISOcountry.php', { country : val }, populateISOcountry, 'html');
function populateISOcountry(data) {
    $('#ISOcountry').html(data);
}
jsonisoccountry.php页面的内容

//....DB connection.....
if (!empty($_POST['country'])) {
foreach ($conn->query("SELECT * FROM regions WHERE countryID=".$_POST['country']) as    $row3) {
$html = $row3['isocountry'] ; 

}
die($html);
提前感谢您的帮助

发现问题

var isocode = document.getElementById('ISOcountry').val() 
没有在窗体的隐藏字段上工作

换了这个,工作正常

var isocode = document.getElementById('ISOcountry').value;
var isocode = document.getElementById('ISOcountry').value;