Php 在google map in coordinator中放置多个PIN时出现问题
我想用动态值在谷歌地图中输入多个pin码,下面是我的代码 查看Php 在google map in coordinator中放置多个PIN时出现问题,php,codeigniter,google-maps,google-maps-markers,Php,Codeigniter,Google Maps,Google Maps Markers,我想用动态值在谷歌地图中输入多个pin码,下面是我的代码 查看 <html> <head><?php echo $map['js']; ?></head> <body><?php echo $map['html']; ?></body> 当我运行上面的代码时,只有一个管脚是下降的,但我希望有多个管脚具有动态值,所以我如何才能做到这一点?您的所有建议都将非常有用。用以下代码替换您的代码: 控制器: $ad
<html>
<head><?php echo $map['js']; ?></head>
<body><?php echo $map['html']; ?></body>
当我运行上面的代码时,只有一个管脚是下降的,但我希望有多个管脚具有动态值,所以我如何才能做到这一点?您的所有建议都将非常有用。用以下代码替换您的代码: 控制器:
$address[ ]=Your multiple address //store your multiple address in array
foreach($address as $add)
{
$prepAddr = str_replace(' ','+',$add);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
$marker = array();
$marker['position'] = $lat.','.$long;
$marker['infowindow_content'] = '$add';
$marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
$this->googlemaps->add_marker($marker);
}
$data['map'] = $this->googlemaps->create_map();
$this->load->view('test',$data);
你的观点是完美的,不需要改变
$address[ ]=Your multiple address //store your multiple address in array
foreach($address as $add)
{
$prepAddr = str_replace(' ','+',$add);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
$marker = array();
$marker['position'] = $lat.','.$long;
$marker['infowindow_content'] = '$add';
$marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
$this->googlemaps->add_marker($marker);
}
$data['map'] = $this->googlemaps->create_map();
$this->load->view('test',$data);