我按照本指南使用 php 设置了谷歌地图脚本。
我复制了所有内容,按照他们所说的创建了表格并插入了记录。当我检查xml 的输出时,一切都很好。当我查看地图时,我看不到位置。
我没有提供代码,因为它是我附加的链接中代码的副本。
您在脚本中使用了错误的路径:
downloadUrl("phpsqlajax_genxml.php"
但它必须是:
downloadUrl("phpsqlajax_genxml3.php"
//----------------------------^
检查您的加载函数并确保传递给下载 url 函数时的 php 文件名正确
//.php create this form and paste it don't forget float datatype your attribute value in the database
//controller.php is when the action performed on controller.php when the user enter submit button
$action = (isset($_GET['action']) && $_GET['action'] != '') ? $_GET['action'] : '';
switch ($action) { case 'add' : doInsert(); 休息;
case 'edit' :
doEdit();
break;
case 'delete' :
doDelete();
break;
case 'photos' :
doupdateimage();
break;
case 'picture' :
UploadImage();
break;
}
function doInsert(){
if(isset($_POST['save'])){
if ( $_POST['LATITUDE'] == "" || $_POST['LONGITUDE'] == "" {
$messageStats = false;
message("All field is required!","error");
redirect('index.php?view=add');
}else{
$branch = New Branch();
$branch->LATITUDE = $_POST["LATITUDE"];
$branch->LONGITUDE = $_POST["LONGITUDE"];
$branch->create();
message("New Location created successfully!", "success");
redirect("index.php");
}
}
}
//to control your navigation or your action add this code in to index.php
$view = (isset($_GET['view']) && $_GET['view'] != '') ? $_GET['view'] : '';
$header=$view;
$title="Branch";
switch ($view) {
case 'list' :
$content = 'list.php';
break;
case 'add' :
$content = 'add.php';
break;
case 'edit' :
$content = 'edit.php';
break;
case 'view' :
$content = 'view.php';
break;
default :
$content = 'list.php';
} ?> //add.php 找到您的纬度和经度位置编号并添加所需的字段纬度:
<div class="col-md-8">
<input class="form-control input-sm" id="LATITUDE" name="LATITUDE" placeholder=
"latitude." type="text" value="" autocomplete="none">
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8">
<label class="col-md-4 control-label" for=
"LONGTIUDE">Longtiude:</label>
<div class="col-md-8">
<input class="form-control input-sm" id="BRANCHCONTACTNO" name="LONGTIUDE" placeholder=
"Longtiude" type="text" value="" autocomplete="none">
</div>
</div>
</div>
// view.php 添加这个以显示来自数据库的数据 Google Map LocationLATITUDE;?>,LONGITUDE; ?>&输出=嵌入">