Codeigniter 代码点火器-Can';t在google maps V3 API中检测我当前的纬度/经度位置
我想显示我当前的纬度/经度。这是我的控制器的源代码。我为CI加载google maps V3 API库。 问题是当我回显“$center\u lat”(我的纬度)和“$center\u long”(我的经度)时,我当前的纬度/经度显示错误的值你能帮我找到我当前位置的真实纬度和经度吗??Codeigniter 代码点火器-Can';t在google maps V3 API中检测我当前的纬度/经度位置,codeigniter,google-maps-api-3,Codeigniter,Google Maps Api 3,我想显示我当前的纬度/经度。这是我的控制器的源代码。我为CI加载google maps V3 API库。 问题是当我回显“$center\u lat”(我的纬度)和“$center\u long”(我的经度)时,我当前的纬度/经度显示错误的值你能帮我找到我当前位置的真实纬度和经度吗?? function GetMarkers() { $this->load->library('googlemaps'); $config
function GetMarkers()
{
$this->load->library('googlemaps');
$config = array();
$config['center'] = 'auto';
$config['onboundschanged'] = 'if (!centreGot)
{
var mapCentre = map.getCenter();
marker_0.setOptions({
position: new google.maps.LatLng(mapCentre.lat(), mapCentre.lng())
});
}
centreGot = true;';
$this->googlemaps->initialize($config);
$marker = array();
$marker['position'] = $config['center'];
$marker['infowindow_content'] = 'Current Position !';
$marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|6FBA33|000000';
$this->googlemaps->add_marker($marker);
$center_lat = $this->googlemaps->markersInfo['marker_0']['latitude'];
$center_long = $this->googlemaps->markersInfo['marker_0']['longitude'];
echo $center_lat . " <----> " . $center_long;
}
函数GetMarkers()
{
$this->load->library('googlemaps');
$config=array();
$config['center']='auto';
$config['onboundschanged']='如果(!centreGot)
{
var mapcenter=map.getCenter();
标记_0.setOptions({
位置:新的google.maps.LatLng(mapcenter.lat(),mapcenter.lng())
});
}
centreGot=true;';
$this->googlemaps->initialize($config);
$marker=array();
$marker['position']=$config['center'];
$marker['infowindow\u content']=“当前位置!”;
$marker['icon']='http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|6FBA33 | 000000';
$this->googlemaps->add_marker($marker);
$center_lat=$this->googlemaps->markersInfo['marker_0']['latitude'];
$center_long=$this->googlemaps->markersInfo['marker_0']['longitude'];
回声$center\u lat.“.”$center\u long;
}
@Andikk-感谢您使用我的库。首先,在您的问题中,您应该真正链接到正在使用的任何库/插件,以便人们能够提供更多帮助。在您在评论中提到它之前,有人怎么知道您正在使用这个特定的库 在回答您的问题时,地理编码实际上是由googlemapsapi在JavaScript中完成的,因此,这些信息在PHP中不会像您尝试的那样可用 如果出于任何原因需要PHP中的值,恐怕AJAX请求将是唯一的选择
希望这能为您指明正确的方向。您目前的位置如何?这是怎么一回事?应该是什么?我使用谷歌地图库。这就是我获取当前位置的方式-->$config['center']='auto'。我得到了错误的纬度/经度位置值。这不是谷歌地图Javascript API v3的一部分。这是一个codeigniter的东西吗?是的,这就是为什么我用它。这里是链接:感谢创建谷歌地图库。这对我有帮助。是的,你是对的,现在我使用javascript来了解我的当前位置