嗨,我在制作函数结构时遇到了一些问题。将不胜感激任何帮助。
首先,一旦从index.php触发OnChange事件,此函数应删除地图标记。并将 post 值发送到xmlmapquery.php以进行数据检索。一旦检索到,数据应该存储回我的index.php中<div id='content'>
function filter()
{
for (var i = 0; i < markersArray.length; i++ ) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
var lgu = $('#lgu').val();
var category = $('#category').val();
var type = $('#type').val();
$.get('xmlmapquery.php', { filter: lgu, filter2: category, filter3: type},function(data){
$('#content').text(data);
)};
};
现在这是xmlmapquery.php
<?php
include('connection_db.php');
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
if(isset($_POST['filter']) && isset($_POST['filter2']) && isset($_POST['filter3'])){
$query = "SELECT * FROM markers WHERE type='".$_POST['filter']."' and type='".$_POST['filter2']."'
and type='".$_POST['filter3']."'";
}
// Select all the rows in the markers table
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("type", $row['type']);
}
echo $dom->saveXML();
?>
将不胜感激这方面的帮助。目前,即使删除标记也不起作用,该功能也不起作用。一旦我得到这个东西,我将向函数添加更多命令,这些命令将获取数据并为我的地图创建新标记。提前致谢。