我需要使用Leaflet帮助自定义地图。我想在自定义地图中测试最多1,000,000个标记,但我无法获得超过400,000个标记。我检查了错误日志,似乎没有任何显示任何错误。我还将最大执行时间设置为300秒,内存限制为1536MB。
Markers.php是一个PHP文件,可以动态加载数据库中的所有标记并用JavaScript输出。我目前正在使用jQuery的getScript函数来加载markers.php文件,然后在加载后设置地图。
markers.php
header('Content-Type: application/javascript');
...
$n = $_GET['n'] ? $_GET['n'] : 50;
try {
$n1 = round($n / 2);
$n2 = $n - $n1;
}
catch(Exception $e){
die('Caught exception: '.$e->getMessage()."\n");
}
try {
$markers1 = select("*", "`properties-ca`", "", "LIMIT 0,$n1");
$markers2 = select("*", "`properties-fl`", "", "LIMIT 0,$n2");
}
catch(Exception $e) {
die('Caught exception: '.$e->getMessage()."\n");
}
echo 'var addressPoints1 = [';
try {
foreach ($markers1 as $m) {
echo "[{$m['latitude']}, {$m['longitude']}, \"{$m['address']}, {$m['city']}, {$m['state']}\"],";
}
}
catch(Exception $e) {
die('Caught exception: '.$e->getMessage()."\n");
}
echo '];';
echo 'var addressPoints2 = [';
try {
foreach ($markers2 as $m) {
echo "[{$m['latitude']}, {$m['longitude']}, \"{$m['address']}, {$m['city']}, {$m['state']}\"],";
}
}
catch(Exception $e) {
die('Caught exception: '.$e->getMessage()."\n");
}
echo '];';
...
的index.php
...
<script>
//$n is the number of markers to load
$.getScript("markers.php?n=<?=$n?>", function(){
Set up map here after loading markers.php
});
</script>
...
for (var i = 0, l = addressPoints1.length; i < l; ++i) {
var m = new PruneCluster.Marker(addressPoints1[i][0], addressPoints1[i][1], {title: addressPoints1[i][2]},/^\d+$/.test(addressPoints1[i][2]) ? 5: 1);
leafletView.RegisterMarker(m);
}
for (var i = 0, l = addressPoints2.length; i < l; ++i) {
var m = new PruneCluster.Marker(addressPoints2[i][0], addressPoints2[i][1], {title: addressPoints2[i][2]},/^\d+$/.test(addressPoints2[i][2]) ? 5: 1);
leafletView.RegisterMarker(m);
}
...
我正在测试的网站是leaflet.ssecure.co。
如果有人知道如何解决这个问题,我将非常感激。
答案 0 :(得分:0)
问题出在您的(标记)PHP文件中。请确保您已启用display_errors
且error_reporting
设置为E_ALL
,因此PHP将抛出错误,而不是返回空白500服务器错误。您还可以检查您的网络服务器错误日志。
http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors http://php.net/manual/en/function.error-reporting.php
我的猜测是你的数据库失败了,因为它会毫不费力地返回100000个标记,所以你也可以在你的实际查询周围放一个try / catch块来查看是否会抛出当前滑过的任何异常。