【问题标题】:How to add many GoogleMaps-Marker in cakePHP on a map如何在地图上的 cakePHP 中添加许多 GoogleMaps-Marker
【发布时间】:2013-02-24 11:48:49
【问题描述】:

我有一个大约 100 个地址的小地址数据库。所以现在我添加了来自 https://github.com/marcferna/CakePHP-GoogleMapHelper 的 Helpper。

我知道如何将地址添加到视图中。但是如何将所有地址添加到一张地图中?

大家可以帮帮我吗?

在此先感谢

马库斯

【问题讨论】:

    标签: google-maps cakephp view helper cakephp-2.3


    【解决方案1】:

    为什么要加逗号?

    <?php $this->GoogleMap->addMarker("map_canvas",1, $atla['Atla']['street'].' '.$atla['Atla']['number'].', '.$atla['Atla']['zipcode'].' '.$atla['Atla']['city'],$atla['Atla']['name'])?> <?php endforeach; ?>
    

    应该是

    <?php $this->GoogleMap->addMarker("map_canvas",1, $atla['Atla']['street'].' '.$atla['Atla']['number'].', '.$atla['Atla']['zipcode'].' '.$atla['Atla']['city'].','.$atla['Atla']['name'])?> <?php endforeach; ?>
    

    但是:http://www.dereuromark.de/2010/12/21/googlemapsv3-cakephp-helper/ 怎么样? 它可能是一个更完整的选择。

    据记载,您可以使用

    $this->GoogleMapV3->addMarker($options);
    

    任意多次。我尝试了 500 并且 - 尽管此时您可能想要切换到集群 - 它仍然有效。

    【讨论】:

    • The Problem is that now i get an error 'extract() expects parameter 1 to be array, string given 这是我的 foreach &lt;?php foreach ($atlas as $atla): ?&gt; &lt;?php $this-&gt;GoogleMap-&gt;addMarker("map_canvas",1, $atla['Atla']['street'].' '.$atla['Atla']['number'].', '.$atla['Atla']['zipcode'].' '.$atla['Atla']['city'],$atla['Atla']['name'])?&gt; &lt;?php endforeach; ?&gt;
    • extract() 代码在哪里?确保您传递给 extract() 的任何内容都是一个数组。
    • 好吗?!错误不会显示,但也没有标记 &lt;?php $this-&gt;GoogleMap-&gt;addMarker("map_canvas",1, array($atla['Atla']['street'].' '.$atla['Atla']['number'].', '.$atla['Atla']['zipcode'].' '.$atla['Atla']['city']),"testing")?&gt; 添加应该看起来像这样 $this->GoogleMap->addMarker("map_canvas",1,"Neckarstraße 150A, 70190 Stuttgart", $marker_options)
    • 哦,你没有正确阅读这篇文章。您使用了错误的助手。请注意,我的链接有一个完全不同(更完整)的谷歌地图助手版本。它们不相关。
    • 包含正确的文件 - 将您的 js 文件重命名为“jquery.js”或包含“jquery-1.9.1.min.js”,而不是介于两者之间...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-08
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    • 2019-11-12
    相关资源
    最近更新 更多