0

工作正常

我只需要显示输入的用户名和密码的项目。我无法将 php 变量发送到 javascript 以回调数据库并更新地图

我有这个代码工作正常(只有一部分):

function initialize() {
var myOptions = {
zoom: 10,
//center: new google.maps.LatLng(-33.9, 151.2),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
                            myOptions);
 <?
$query = mysql_query("SELECT lat2,lon2,idruta,FROM_UNIXTIME(time) as time FROM bus");
$valores="[";
$indice = 0;
while ($row = mysql_fetch_array($query)){
$namex=$row['idruta'];
$lat=$row['lat2'];
$lon=$row['lon2'];
$desc = $row['time'];
$name = $namex ." ".$desc;
$indice++;
$valores = $valores. "['$name',$lat,$lon,$indice],";
}
$valores = substr($valores, 0, -1);
$valores = $valores ."]";
echo ("setMarkers(map, $valores)");
?>

// setMarkers(map, beaches);
}
function codeAddress() {
 var myOptions = {
zoom: 10,
//center: new google.maps.LatLng(-33.9, 151.2),
mapTypeId: google.maps.MapTypeId.ROADMAP
 }
var map = new google.maps.Map(document.getElementById("map_canvas"),
                            myOptions);
<?
$query = mysql_query("SELECT lat2,lon2,idruta,FROM_UNIXTIME(time) as time FROM bus where user = $user");
$valores="[";
$indice = 0;
while ($row = mysql_fetch_array($query)){
$namex=$row['idruta'];
$lat=$row['lat2'];
$lon=$row['lon2'];
$desc = $row['time'];
$name = $namex ." ".$desc;
$indice++;
$valores = $valores. "['$name',$lat,$lon,$indice],";
}
$valores = substr($valores, 0, -1);
$valores = $valores ."]";
echo ("setMarkers(map, $valores)");
?>
}
function setMarkers(map, locations) {
 var image = new google.maps.MarkerImage('marker-panel.png',
 new google.maps.Size(220, 39),
 new google.maps.Point(0,0),
 new google.maps.Point(50, 39));
/* var shadow = new google.maps.MarkerImage('marker-panel.png',
      new google.maps.Size(37, 32),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 32));*/
 var shape = {
      coord: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'
 };
 var bounds = new google.maps.LatLngBounds();
 for (var i = 0; i < locations.length; i++) {
      var beach = locations[i];
      var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
      var marker = new google.maps.Marker({
           position: myLatLng,
           map: map,
           //shadow: shadow,
           icon: image,
           shape: shape,
           title: beach[0],
          zIndex: beach[3]
      });
      bounds.extend(myLatLng);
      var label = new Label({
           map: map
      });
      label.set('zIndex', 1234);
      label.bindTo('position', marker, 'position');
      label.set('text', beach[0]);
      //label.bindTo('text', marker, 'position');
  }
  map.fitBounds(bounds);
 }
 </script>
 </head>
 <body onload="initialize()">
 <div>
  <input id="usuario" type="textbox" value="usuario">
  <input id="password" type="password" value="password">
  <input type="button" value="Enviar" onclick="codeAddress()">
</div>
<div id="map_canvas" style="height:90%;top:30px"></div>
</body>
</html>

但我只需要显示输入的用户积分和密码。我不知道

谢谢

4

1 回答 1

0

在调用这些 java 脚本函数之前,编写一段 php 代码来检查用户点和密码。如果用户点和密码正确,则意味着只调用那些脚本。

于 2013-03-05T10:20:32.163 回答