【发布时间】:2013-12-28 17:00:11
【问题描述】:
我正在使用 GoogleMapsHelper 和 CakePHP 在我的应用程序中包含一个 Google 地图。
为了给我的地图添加标记,文档说我应该使用以下语法,其中三个变量是地图 ID、标记 ID 和标记位置。
<?= $this->GoogleMap->addMarker("map_canvas", 1, array('latitude' => 40.69847, 'longitude' => -73.9514)); ?>
考虑到这一点,我一直在尝试遍历我的数据库并显示我的所有观点,但它没有做任何事情:这是代码,每个帖子都有 (lat) 和 (lng)。
<?php
foreach ($posts as $post): ?>
<?php $this->GoogleMap->addMarker("map_canvas", $post['Post']['id'], array('latitude' => $post['Post']['lat'], 'latitude' => $post['Post']['lng'])); ?>
<?php endforeach; ?>
如何将这些条目作为标记加载到我的地图中? 提前致谢!
【问题讨论】:
-
更新版本可能是this
标签: php google-maps cakephp google-maps-api-3 cakephp-2.4