我正在尝试在 google maps api v3 中保存一个绘制对象的数组。
MySql 表如下所示:
CREATE TABLE circles
(
lat INT,
lng INT,
radius INT,
fillColor VARCHAR(9),
fillOpacity INT
);
php 文件 save_circle.php:
<?php
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
$radius = $_REQUEST['radius'];
$fillColor = $_REQUEST['fillColor'];
$fillOpacity = $_REQUEST['fillOpacity'];
include 'conn.php';
$sql = "insert into circles(lat,lng,radius,fillColor,fillOpacity)
values('$lat','$lng','$radius','$fillColor','$fillOpacity')";
$result = @mysql_query($sql);
if ($result){
echo json_encode(array('success'=>true));
} else {
echo json_encode(array('msg'=>'Some errors occured.'));
}
?>
HTML 喜欢:
google.maps.event.addDomListener(savebutton, 'click', function() {
for (var i = 0; i < circles.length; i++) {
var data = [lat, lng, radius, fillColor, fillOpacity];
/* var data = {
lat: circle.getCenter().lat(),
lng: circle.getCenter().lng(),
radius: circle.getRadius(),
fillColor: circle.get('fillColor'),
fillOpacity: circle.get('fillOpacity'),
}; */
trace(data)
//send the results to the PHP script that adds the circle to the database
$.post("save_circle.php", data, circle.saveStopResponse, "json");
}
});
跟踪(数据)返回:
45.108423337694084
-71.8560791015625
22322.63536250027
#ff0000
0.45
控制台返回:
[45.108423337694084, -71.8560791015625, 22322.63536250027, "#ff0000", 0.45]
{"msg":"Some errors occured."}
我错过了什么吗?
谢谢