【问题标题】:Codeigniter Google maps apiCodeigniter 谷歌地图 api
【发布时间】:2014-05-15 17:14:01
【问题描述】:

我刚刚测试了 google maps api to codeigniter,但出现了一个我不理解的错误。 严重性:通知 消息:未定义的变量:地图

代码来自这里

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

【问题讨论】:

  • 您确定要加载“googlemaps”库吗?
  • 类映射扩展 CI_Controller { function index() { $this->load->library('googlemaps'); $config['center'] = '35.825795, 10.607212'; $config['zoom'] = 'auto'; $config['directions'] = TRUE; $config['directionsStart'] = '苏塞铁路'; $config['directionsEnd'] = '苏塞南'; $config['directionsDivID'] = 'directionsDiv'; $this->googlemaps->初始化($config); $data['map'] = $this->googlemaps->create_map(); $this->load->view('maps', $data); } }

标签: codeigniter maps


【解决方案1】:
if (isset($_GET["w1"]) && isset($_GET["w2"]))
{
    $config['center'] = $lat = $_GET["w1"].','.$lng = $_GET["w2"];
    $marker = array();        
    $marker['position'] = $lat = $_GET["w1"].','.$lng = $_GET["w2"];
    $latlng = $_GET["w1"].','.$_GET["w2"];
    $request = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=.$latlng.&key=AIzaSyAOAR94QMB9YdE8RXHG-8NE28cz6wdUw2I');
    $json = json_decode($request, true);                                            
    $marker['infowindow_content'] = implode("|", $json);
    $this->googlemaps->add_marker($marker);             
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    相关资源
    最近更新 更多