-1

我在我的蛋糕 PHP 上添加谷歌地图时遇到问题。请给我一些关于如何在我的网页上添加简单的谷歌地图页面的建议。

我的代码在这里:

 class GooglemapsController extends AppController
{
    var $ext = ".php";
    public $helpers = array('GoogleMap');       
        public function index()
        {


        }
            public function map()
            {

            }
}` 
4

2 回答 2

1

您可以使用https://github.com/marcferna/CakePHP-GoogleMapHelper。将地图添加到视图中并添加标记和更多自定义的简单方法。

于 2013-09-23T01:00:49.103 回答
0
[enter link description here][1]

Add below helper on app/view/helper/

And add this code of default.ctp

html->script('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'); ?> Html->script('https://maps.google.com/maps/api/js?sen sor=true'); ?>
And Add below code on your view page:
  <?php
      $map_options = array(
        "id"         => "map_canvas",
        "width"      => "500px",
        "height"     => "500px",
        "localize"   => false,
        "zoom"       => 10,
        "address"    => "Manhattan, NY",
        "marker"     => true,
        "infoWindow" => true
      );
    ?>

    // print the default map
    <?= $this->GoogleMap->map($map_options); ?>

    // add the marker with latitude and longitude
    <?= $this->GoogleMap->addMarker("map_canvas", 1, array("latitude" => 40.69847, "longitude" => -73.9514)); ?>

    // add the marker with address
    <?= $this->GoogleMap->addMarker("map_canvas", 2, "Queens, NY"); ?>
  [1]: https://github.com/marcferna/CakePHP-GoogleMapHelper/blob/master/GoogleMapHelper.php
于 2015-08-17T14:29:48.000 回答