【问题标题】:Change center of map according to autocomplete input using google maps codeigniter library使用谷歌地图codeigniter库根据自动完成输入更改地图中心
【发布时间】:2015-05-01 06:41:01
【问题描述】:

当我使用谷歌地图 codeigniter 库的“placesautocompleteonchange”时,我无法获得地图的中心。

首先,当页面加载时,地图的中心被设置为一个特定的城市(这是我指定的) $config['center'] = '8.457348645837307,124.63308727385254';

然后我指定了一些配置来激活自动完成功能。

   `$config['places'] = TRUE;
    $config['placesAutocompleteInputID'] = 'address';
    $config['placesAutocompleteBoundsMap'] = TRUE;`

然后我还要添加一个标记配置

    `$marker = array();
    $marker['draggable'] = true;`

我的问题是,我不知道如何根据输入字段中输入的地址更改地图的中心,并根据当前地图的中心更改标记的位置。

我希望有人可以帮助我。谢谢

(对不起我的英语不好)

P.S:我使用了 Sir BIOSTALL 的 Google Maps V3 Codeigniter 库

【问题讨论】:

    标签: php codeigniter google-maps google-maps-api-3


    【解决方案1】:

    只需使用$this->input->post() 获取输入,然后将两个值与explode 组合成一个字符串

    如需更多帮助,请阅读

    1. http://www.codeigniter.com/user_guide/
    2. http://biostall.com/demos/google-maps-v3-api-codeigniter-library/placesautocomplete

    $center = implode(',', array(
         $this->input->post('lat'),
         $this->input->post('lon')
    ));
    
    $config['center'] = $center;
    $marker['position'] = $center;
    

    【讨论】:

      猜你喜欢
      • 2017-03-01
      • 1970-01-01
      • 2015-09-16
      • 2016-11-14
      • 2019-01-25
      • 2014-08-14
      • 2016-11-17
      • 2018-01-26
      相关资源
      最近更新 更多