當員工登錄時,我們需要自動檢索當前位置並插入它。這是一個在線打卡輸入/輸出系統。因此,只要確保輸入/輸出不會因其他地方的輸入/輸出而被濫用。使用http://ipinfo.io/
作爲Gaurang Joshi在下面提到的我得到互聯網知識產權和緯度和logitudes.So我需要使用任何谷歌地圖庫得到具體位置?如何實現它?任何幫助。如何在codeigniter中獲取當前位置和網絡IP?
回答
服務器IP
要獲取$_SERVER['SERVER_ADDR']
本地IP服務器IP地址
要通過$_SERVER['REMOTE_ADDR']
要查找的位置根本就獲取客戶端IP:
//ipinfo grabs the ip of the person requesting
$getloc = json_decode(file_get_contents("http://ipinfo.io/"));
echo $getloc->city; //to get city
如果您使用座標它像32單個字符串返回,-72所以,對於您可以使用:
$coordinates = explode(",", $getloc->loc); // -> '32,-72' becomes'32','-72'
echo $coordinates[0]; // latitude
echo $coordinates[1]; // longitude
這將返回互聯網IP權利除了locatoin,有沒有什麼辦法可以獲得網絡IP?所以,當用戶我們可以從其他網絡登錄來追蹤它。 –
先生,還得到的位置我需要使用谷歌地圖庫?因爲上面的$ getloc->城市只是返回新加坡和確切位置沒有提到,所以我想我需要嘗試找到位置使用獲得的經度和緯度。 –
你的網址是什麼意思?那個MAC地址? –
公共功能指數(){
$ip = $_SERVER['REMOTE_ADDR'];
//$location = file_get_contents('http://freegeoip.net/json/'.$_SERVER['REMOTE_ADDR']);
$location = file_get_contents('http://ip-api.com/json/'.$ip);
//print_r($location);exit;
$data_loc = json_decode($location);
$marker = array();
$data = array(
'view_file'=>'index',
'current_menu'=>'index',
'site_title' =>'site title',
'logo' => 'logo',
'title'=>'Family Owned Pest Control',
);
$Lat = '';
$Lon = '';
if(isset($_GET['searchsubmit']))
{
$Address = $this->input->get('addr_loc');
$jobtitle = $this->input->get('jobtitle');
$request_url = "//maps.googleapis.com/maps/api/geocode/xml?address=".$Address."&sensor=true";
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;
if ($status=="OK") {
$Lat = $xml->result->geometry->location->lat;
$Lon = $xml->result->geometry->location->lng;
}
}
if(empty($Lat) AND empty($Lon))
{
$config['center'] = 'auto';
$marker['position'] = $data_loc->lat.",". $data_loc->lon ;
$Lat = $data_loc->lat;
$Lon = $data_loc->lon;
}
else{
$config['center'] ='auto';
$marker['position'] = $Lat.",". $Lon ;
}
$config['zoom'] = '11';
$config['places'] = TRUE;
$config['placesAutocompleteInputID'] = 'myPlaceTextBox';
$config['placesAutocompleteBoundsMap'] = TRUE; // set results biased towards the maps viewport
$this->googlemaps->initialize($config);
$marker['infowindow_content'] = $data_loc->city.'<br>'.$data_loc->regionName.'<br>'.$data_loc->country;
$marker['icon'] = '//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
$this->googlemaps->add_marker($marker);
$Lat1 = $Lat+0.05;
$Lon1 = $Lon+0.05;
$marker = array();
$marker['position'] = $Lat1.",". $Lon1;
$marker['draggable'] = TRUE;
$marker['animation'] = 'DROP';
$marker['infowindow_content'] = 'dskjfhdsjhfsd' ;
$marker['icon'] = '//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=B|9999FF|000000';
$this->googlemaps->add_marker($marker);
$Lat2 = $Lat1+0.05;
$Lon2 = $Lon1+0.05;
$marker = array();
$marker['position'] = $Lat2.",". $Lon2;
$marker['draggable'] = TRUE;
$marker['animation'] = 'DROP';
$marker['infowindow_content'] = 'dskjfhdsjdsfsdfhfsd' ;
$marker['icon'] = '//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=C|9999FF|000000';
$this->googlemaps->add_marker($marker);
$data['content']='content/peta';
$data['map'] = $this->googlemaps->create_map();
$this->template->load_index_template($data);
}
- 1. 如何獲取當前的網絡位置名稱?
- 2. 如何在xcode中使用互聯網獲取當前位置?
- 3. 如何獲取CodeIgniter中的獲取請求的當前網址?
- 4. 如何獲得谷歌地圖的網絡當前位置
- 5. 獲取當前位置並將其發佈到網絡服務
- 6. 獲取當前位置使用網絡提供商的名稱
- 7. 獲取與GPS /網絡的Android MapView的用戶當前位置
- 8. 如何在global.asax中獲取當前網站的IP地址?
- 9. 如何獲取並設置當前網頁滾動位置?
- 10. 如何獲取當前位置
- 11. 如何獲取當前的iScroll位置?
- 12. 如何獲取當前位置android?
- 13. 如何獲取用戶當前位置
- 14. 如何獲取當前位置Gmaps V2 ..?
- 15. 如何獲取當前的GPS位置?
- 16. 如何在Excel VBA中獲取當前網絡的名稱?
- 17. 如何在android中獲取前景的當前位置?
- 18. 在android中獲取當前位置
- 19. 在GPS中獲取當前位置?
- 20. 在mysql表中獲取當前位置
- 21. 在Android中獲取網絡IP地址
- 22. 獲取當前位置
- 23. 獲取當前位置
- 24. 獲取當前位置
- 25. 獲取當前位置
- 26. 獲取當前位置android
- 27. 獲取當前位置ImageView
- 28. Android獲取當前位置
- 29. android獲取當前位置
- 30. 在osmdroid上與網絡供應商取得當前位置
請提供一個例子以及在哪裏保存你的位置? – Priyank
選中此項可能對您有所幫助。 [http://theonlytutorials.com/user-current-location-ip-address-simple-php-script/] –