这是我的静态数组,我一直在用它在谷歌地图上显示这条线。
$polyline = array();
$polyline['points'] = array('-6.343, 106.814',
'-6.343, 106.8143',
'-6.34567, 106.8140');
$marker['infowindow_content'] = 'Mobil 1!';
$marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
$this->googlemaps->add_polyline($polyline);
$data['map'] = $this->googlemaps->create_map();
我想从JSON中获得一个动态数据,并将其放在下面的数组中。
$polyline['points'] = array('-6.343, 106.814',
'-6.343, 106.8143',
'-6.34567, 106.8140');
我一直在尝试创建以下函数。
public function testGetMap() {
$this->load->model('modelMap');
$getMap = $this->modelMap->getMap();
$encoded = json_encode($getMap, JSON_NUMERIC_CHECK);
$decoded = json_decode($encoded,TRUE);
$a = array();
foreach($decoded as $item) {
array_push($a, $item['latitude'].','.$item['longitude']);
}
var_dump($polyline['points']);
}
并在该特定函数上调用此函数。
$polyline['points'] = $this->testGetMap();
但它根本不起作用。请帮忙。
Juste更换
var_dump($polyline['points']);
带
return $a;
数组$a
应在函数定义区域内返回。这不在这里。这就是为什么它没有反映出来。