我正在尝试使用带有随机坐标的 Maps API,但我不知道,我需要一些信息,如何将 .js 文件中的 php 值从 php 文件中放入 javascript 函数中?例如,如果我们有几个代码:
1)API代码生成2坐标之间的路线(order2.js):
(function() {
window.onload = function() {
// Creating a map
var options = {
zoom: 8,
center: new google.maps.LatLng(-33.3834, -70.6),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), options);
// Creating an array that will contain the points for the polyline
var route = [
new google.maps.LatLng(-33.02644,-71.539775),
new google.maps.LatLng(-33.605148,-70.702197)
];
// Creating the polyline object
var polyline = new google.maps.Polyline({
path: route,
strokeColor: "#ff0000",
strokeOpacity: 0.6,
strokeWeight: 5
});
// Adding the polyline to the map
polyline.setMap(map);
};
})();
2)谷歌地图API代码显示(map2.html):
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chapter 4 - Google Maps API 3</title>
<link rel="stylesheet" href="css/graphic.css" type="text/css" media="all" />
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/order2.js"></script>
</head>
<body>
<input type="button" value="getValues" id="getValues" />
<input type="button" value="changeValues" id="changeValues" />
<div id="map"></div>
</body>
</html>
3)如果我有下一个浮动随机代码(random.php):
<?php
while($x <= 2995 and $y <= 71333)
{
$x = rand(2025,2995);
$y = rand(70116,71333);
$w = $x/100;
$z = $y/1000;
echo $w."<br>".$z."<br>";
}
?>
现在根据之前的代码,我真的需要知道:
如何将 $w 和 $z 值从 random.php 传输到与 order2.js 相关的任何函数(a,b)?
感谢您的有用帮助。
问候