如何在codeigniter中使用谷歌地图连接多个标记?

时间:2014-08-06 08:18:38

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

我必须连接多个标记点才能在谷歌地图中显示方向。我用过codeigniter。我已经提到了link

没有标记之间连接路线的示例。请帮助我。

控制器:

public function geoLocation(){

        $this->load->library('googlemaps');

        $config['center'] = '37.4419, -122.1419';
        $config['zoom'] = 'auto';
        $config['directions'] = TRUE;
        $config['directionsStart'] = 'Hadapsar, Pune, India';
        //$config['directionsDivID'] = 'swargate, Pune, India';
        $config['directionsEnd'] = 'Bavdhan, Pune, India';

        $this->googlemaps->initialize($config);


        $data['map'] = $this->googlemaps->create_map();

        $this->load->view('google-map', $data);

}

我更新的控制器方法:

public function index()
    {
        $this->load->library('googlemaps');

        $config['center'] = 'Pune, India';
        $config['zoom'] = 'auto';
        $config['directionsMode']="WALKING";
        $config['directionsWaypointArray'] = array('Hadapsar, Pune, India','Swargate, Pune, India','Bavdhan, Pune, India');

        $this->googlemaps->initialize($config);

        $marker = array();
        $marker['position'] = 'Hadapsar, Pune, India';
        //$marker['onmouseover'] = 'ahssdfsdf';
        $marker['infowindow_open']= true;

        $this->googlemaps->add_marker($marker);



        $marker['position'] = 'Bavdhan, Pune, India';

        $this->googlemaps->add_marker($marker);
        $data['map'] = $this->googlemaps->create_map();

        $this->load->view('welcome_message', $data);
    }
}

这是我的HTML代码:

<?php echo $map['js']; ?>
    <div id="nevi">
                <div id="menu">
                  <div id="TabbedPanels1" class="TabbedPanels">
                    <ul class="TabbedPanelsTabGroup">
                      <li class="TabbedPanelsTab"  tabindex="0" style="font-size:14px" id="today_st">Today's status </li>
                      <li class="TabbedPanelsTab" id="report" tabindex="0"  style="font-size:14px">Reports</li>
                    </ul>
                    <div class="TabbedPanelsContentGroup" style="margin-top:74px;">

                      <div class="TabbedPanelsContent">
                      <?php echo $map['html']; ?>
                      </div>
                    </div>
                  </div>
                </div>
  </div>

1 个答案:

答案 0 :(得分:1)

您需要指定:

directionsWaypointArray    

根据the code

var $directionsWaypointArray = array(); // An array of waypoints. eg array("Boston, MA", "Times Square, NY");

航点是你的起点和终点之间的位,所以我假设你只需要这样做:

$config['directionsStart'] = 'Hadapsar, Pune, India';
$config['directionsEnd'] = 'Bavdhan, Pune, India';
$config['directionsWaypointArray'] = array("swargate, Pune, India");