【问题标题】:Show route steps using google API in codeigniter在 codeigniter 中使用 google API 显示路线步骤
【发布时间】:2014-07-22 14:22:33
【问题描述】:

我每 15 分钟保存一次纬度和经度。我需要在codeigniter中用谷歌地图上保存的数据标记绘制一条路线。一些例子给出了起点和终点,但我需要在地图上显示我的数据库值。请就该主题提出一些解决方案。

控制器方法:

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'] = 'swargate, Pune, India';

            $config['directionsStart'] = 'swargate, 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);

    }

我的看法:

<html>
<head><?php echo $map['js']; ?></head>
<body><?php echo $map['html']; ?></body>
<div id="directionsDiv"></div>
</html>

检查上面我有三点:Hadapsar、swargate、Bavdhan。我想画三个车站的路线。

【问题讨论】:

  • 到目前为止你尝试了什么,你能展示一些你已经写的代码吗?
  • 我在codeigniter框架(PHP)中尝试过。看一下代码并找到好的解决方案。

标签: codeigniter google-maps gps


【解决方案1】:

感谢您使用我的图书馆。你见过航路点吗?

https://github.com/BIOSTALL/CodeIgniter-Google-Maps-V3-API-Library/blob/master/application/libraries/Googlemaps.php#L130

这可能是您正在寻找的。我能想到的唯一另一件事是,不要使用方向,使用折线:

http://biostall.com/demos/google-maps-v3-api-codeigniter-library/polyline

【讨论】:

  • 不,不是折线。它对我不起作用。我想要起点、中间步骤路线和终点。这些都来自数据库,通过使用这些我想绘制方向和标记。
  • 这是一个仅限链接的边界答案。您应该在此处扩展您的答案以包含尽可能多的信息,并仅将链接用作参考。
【解决方案2】:

我想要相同的结果我有一系列方向我想要绘制路线 我选择这个代码

$this->load->library('googlemaps');
    $config['center'] = 'udaipur, rajasthan, india';
    $config['zoom'] = 'auto';
    $config['directions'] = TRUE;
    $config['directionsMode'] = "WALKING";
    $config['directionsStart'] = '24.5862087,73.6937057';
    $config['directionsWaypointArray'] = array(
        "24.5866843,73.6890816",
        "24.5878709,73.6878411",
        "24.5900044,73.6896301",
        "24.5973893,73.6857516"
        );
    $config['directionsEnd'] = '24.6045763,73.6853708';
    $config['directionsDivID'] = 'directionsDiv';
    $this->googlemaps->initialize($config);
    $data['map'] = $this->googlemaps->create_map();
    $this->load->view('welcome_message', $data);

【讨论】:

    猜你喜欢
    • 2014-10-16
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    相关资源
    最近更新 更多