我想看看如何将 $CITY、$STATE 和 $count 数据包含在 javascript 代码中?
这是非工作代码:
<?php echo('<script type="text/javascript"> var address$count = $CITY$STATE');?>
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.TERRAIN,
zoom: 6
});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address<?php echo($count);?>},
function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
position: results[0].geometry.location,
map: map
});
map.setCenter(results[0].geometry.location);
}
});
</script>
<?php
}
?>
</body>
</html>
谢谢您的帮助!