我正在尝试修复朋友计划....
需要excel电子表格并对地址进行地理编码,并将long和lat存储在数据库中。
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/redmond/jquery-ui.css">
<link rel="stylesheet" href="ls.css">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/polygonEdit.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript" src="js/poly.js"></script>
<script type="text/javascript" src="js/def.js"></script>
<script type="text/javascript" src="js/territory.js"></script>
<script type="text/javascript" src="js/jquery.ui.map.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.map.services.min.js"></script>
<script type="text/javascript">
</script>
调用excel文件,然后对地址进行地理编码 excel上传功能是用PHP编写的
$addr .= $objWorksheet->getCellByColumnAndRow($i, $row_num)->getValue() . ' ';
$a = get_geocode(urlencode(trim($addr)));
function get_geocode($addr) {
// check to see if we have a geocode value
$sql = sprintf("select latitude, longitude from geocodes where address = '%s'", $addr);
$rs = mysql_query($sql) or die (log_msg(mysql_error() . $sql));
if (mysql_num_rows ( $rs) > 0) {
//log_msg('found in db: ' . $addr);
return(mysql_fetch_array($rs));
} else {
// we need to geocode.
$a = geocode(urlencode($addr));
// Save the results to speed up the next search.
if ($a[0] > 0) {
$sql = sprintf("insert into geocodes(address, latitude, longitude) values (%s, %s, %s)", dbquote($addr, 'text'), $a[0], $a[1] );
//log_sql($sql);
mysql_query($sql);
}
return $a;
}
}
地理编码返回:地理错误:610,0,0,0
帮助......