[英]Change center of map according to autocomplete input using google maps codeigniter library
当我使用谷歌地图codeigniter库的'placesautocompleteonchange'时,我很难获得地图的中心。
首先,当页面加载时,地图的中心设置为特定的城市(我指定) $config['center'] = '8.457348645837307,124.63308727385254';
然后我指定了一些配置来激活自动完成功能。
`$config['places'] = TRUE;
$config['placesAutocompleteInputID'] = 'address';
$config['placesAutocompleteBoundsMap'] = TRUE;`
然后我还添加了一个标记配置
`$marker = array();
$marker['draggable'] = true;`
我的问题是,我不知道如何根据输入字段上输入的地址更改地图的中心,并根据地图的当前中心更改标记的位置。
我希望有一个人可以帮助我。 谢谢
(对不起,我的英语不好)
PS:我使用了Sir BIOSTALL的Google Maps V3 Codeigniter库
您 只需要使用$this->input->post()
获取输入,然后将两个值与explode
成一个字符串
如需更多帮助,请阅读
$center = implode(',', array(
$this->input->post('lat'),
$this->input->post('lon')
));
$config['center'] = $center;
$marker['position'] = $center;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.