2014-05-15 139 views
0

我剛剛測試谷歌地圖API Codeigniter,但有一個我不明白的錯誤。 嚴重性:注意 消息:未定義的變量:地圖Codeigniter谷歌地圖API

的代碼是從這裏

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

+0

你確定你正在加載 「Google地圖」 圖書館? – lesssugar

+0

類地圖延伸是CI_Controller { \t功能指數() \t { \t \t $這 - >負載>庫( 'Google地圖'); \t \t $ config ['center'] = '35 .825795,10.607212'; \t \t $ config ['zoom'] ='auto'; \t \t $ config ['directions'] = TRUE; \t \t $ config ['directionsStart'] ='蘇斯鐵路'; \t \t $ config ['directionsEnd'] ='Sousse Sud'; \t \t $ config ['directionsDivID'] ='directionsDiv'; \t \t $ this-> googlemaps-> initialize($ config); \t \t $ data ['map'] = $ this-> googlemaps-> create_map(); \t \t $ this-> load-> view('maps',$ data); \t} } – user3616893

回答

0
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);    
}