手机 window.location总是显示new locaion怎么回事

issue loctaion 是什么意思_百度知道
issue loctaion 是什么意思
我有更好的答案
issue location问题定位.-----------------------------------为你解答,如有帮助请采纳,如对本题有疑问可追问,Good luck!
采纳率:82%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。android接完百度地图 定位我的位置总是北京怎么回事 根据第一行代码里的内容写的_百度知道
android接完百度地图 定位我的位置总是北京怎么回事 根据第一行代码里的内容写的
我有更好的答案
具体代码:1.布局文件?&?xml version=&1.0& encoding=&utf-8&?&&LinearLayout xmlns:android=&&
android:orientation=&vertical&
android:layout_width=&match_parent&
android:layout_height=&match_parent&&
&RelativeLayout
android:layout_width=&match_parent&
android:layout_height=&@dimen/height_top_bar&
android:background=&@color/common_top_bar_dark&
android:gravity=&center_vertical&&
android:id=&@+id/btn_location_back&
android:layout_width=&wrap_content&
android:layout_height=&match_parent&
android:drawableLeft=&@drawable/back&
android:text=&@string/top_back&
style=&@style/btn_title_bar&
android:layout_alignParentLeft=&true&
android:onClick=&back&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:layout_centerInParent=&true&
android:text=&@string/location_message&
style=&@style/txt_titlebar_message&/&&Button
android:id=&@+id/btn_location_ok&
android:layout_width=&52dp&
android:layout_height=&match_parent&
android:layout_alignParentRight=&true&
android:background=&@drawable/common_tab_bg&
android:text=&@string/txt_queding&
style=&@style/btn_title_bar&/&
&/RelativeLayout&
&com.baidu.mapapi.map.MapView
android:layout_weight=&2&
android:id=&@+id/mapview_location&
android:layout_width=&fill_parent&
android:layout_height=&match_parent&
android:clickable=&true& /&
android:layout_weight=&3&
android:id=&@+id/lv_location_nearby&
android:layout_width=&match_parent&
android:layout_height=&match_parent&/& &/LinearLayout&布局文件就是上面是一个百度地图的mapview,下面是一个显示周边位置的ListView,很简单。1、自动定位我们先看一下根据自己的地理位置实现定位 1.首先初始化要用到的组件?/**
* 初始化组件
*/ private void initView() {
btnLocationBack = (Button) findViewById(R.id.btn_location_back);
btnLocationBack.setOnClickListener(this);
btnLocationOk = (Button) findViewById(R.id.btn_location_ok);
btnLocationOk.setOnClickListener(this);
mapViewLocation = (MapView) findViewById(R.id.mapview_location);
lvLocNear = (ListView) findViewById(R.id.lv_location_nearby);
nearList = new ArrayList&PoiInfo&();
adapter = new LocNearAddressAdapter(context, nearList, isSelected);
lvLocNear.setAdapter(adapter); }2.初始化LocationClient类,该类需要在主线程中声明?public LocationClient mLocationClient =public BDLocationListener myListener = new MyLocationListener(); public void onCreate() {
mLocationClient = new LocationClient(getApplicationContext());
//声明LocationClient类
mLocationClient.registerLocationListener( myListener );
//注册监听函数}3.配置定位SDK参数 设置定位参数包括:定位模式(高精度定位模式,低功耗定位模式和仅用设备定位模式),返回坐标类型,是否打开GPS,是否返回地址信息、位置语义化信息、POI信息等等。 LocationClientOption类,该类用来设置定位SDK的定位方式?private void initLocation(){
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
option.setCoorType(&bd09ll&);//可选,默认gcj02,设置返回的定位结果坐标系
int span=1000;
option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
option.setOpenGps(true);//可选,默认false,设置是否使用gps
option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到option.setIgnoreKillProcess(false);//可选,默认false,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认杀死
option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
mLocationClient.setLocOption(option);
}4.实现BDLocationListener接口?/**
* 监听函数,有新位置的时候,格式化成字符串,输出到屏幕中
*/ public class MyLocationListenner implements BDLocationListener {
public void onReceiveLocation(BDLocation location) {
if (location == null) {
Log.d(&map&, &On location change received:& + location);
Log.d(&map&, &addr:& + location.getAddrStr());
if (progressDialog != null) {
progressDialog.dismiss();
if (lastLocation != null) {
if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
Log.d(&map&, &same location, skip refresh&);
// mMapView.refresh(); //need this refresh?
lastLocation =
mBaiduMap.clear();
mCurrentLantitude = lastLocation.getLatitude();
mCurrentLongitude = lastLocation.getLongitude();
Log.e(&&&&&&&&&, mCurrentLantitude + &,& + mCurrentLongitude);
LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
CoordinateConverter converter = new CoordinateConverter();
converter.coord(llA);
converter.from(CoordinateConverter.CoordType.COMMON);
LatLng convertLatLng = converter.convert();
OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
.fromResource(R.drawable.icon_marka))
.zIndex(4).draggable(true);
mCurrentMarker = (Marker) mBaiduMap.addOverlay(ooA);
MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 16.0f);
mBaiduMap.animateMapStatus(u);
new Thread(new Runnable() {
public void run() {
searchNeayBy();
}).start();
public void onReceivePoi(BDLocation poiLocation) {
if (poiLocation == null) {
} }这里接受到的BDLocation中包含好多参数,相信总有一个对你有用的。2、根据经纬度定位这种方法不需要自动定位,就是根据经纬度来显示地图上的位置?/*
* 显示经纬度的位置
private void showMap(double latitude, double longtitude, String address) {//
sendButton.setVisibility(View.GONE);
LatLng llA = new LatLng(latitude, longtitude);
CoordinateConverter converter = new CoordinateConverter();
converter.coord(llA);
converter.from(CoordinateConverter.CoordType.COMMON);
LatLng convertLatLng = converter.convert();
OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marka))
.zIndex(4).draggable(true);
markerA = (Marker) (mBaiduMap.addOverlay(ooA));
u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 16.0f);
mBaiduMap.animateMapStatus(u);
new Thread(new Runnable() {
public void run() {
searchNeayBy();
}).start();
}3、获取周边地理位置最后看一下怎么获取周边的地理位置,这里需要用到SDK中的一个类PoiNearbySearchOption,我们可以看一下类参考:PoiNearbySearchOption keyword(java.lang.String key)检索关键字PoiNearbySearchOption location(LatLng location)检索位置PoiNearbySearchOption pageCapacity(int pageCapacity)设置每页容量,默认为每页10条PoiNearbySearchOption pageNum(int pageNum)分页编号PoiNearbySearchOption radius(int radius)设置检索的半径范围PoiNearbySearchOption sortType(PoiSortType sortType)搜索结果排序规则,可选,默认这里是它的一些方法,我们可以看到我们只需要设置一下关键字、周边位置半径、检索位置、排序规则、分页号、每页数量等。然后我们实现OnGetPoiSearchResultListener这个接口,获取周边地理位置结果。/**
* 搜索周边地理位置
private void searchNeayBy() {
PoiNearbySearchOption option = new PoiNearbySearchOption();
option.keyword(&写字楼&);
option.sortType(PoiSortType.distance_from_near_to_far);
option.location(new LatLng(mCurrentLantitude, mCurrentLongitude));
if (radius != 0) {
option.radius(radius);
option.radius(1000);
option.pageCapacity(20);
mPoiSearch.searchNearby(option);
} /** 接受周边地理位置结果* @param poiResult*/
public void onGetPoiResult(PoiResult poiResult) {
if (poiResult != null) {
if (poiResult.getAllPoi()!=null&&poiResult.getAllPoi().size()&0){
nearList.addAll(poiResult.getAllPoi());
if (nearList != null && nearList.size() & 0) {
for (int i = 0; i & nearList.size(); i++) {
isSelected.put(i, false);
Message msg = new Message();
msg.what = 0;
handler.sendMessage(msg);
}获取完数据之后更新适配器显示周边位置就OK了,最后再实现一个小小的功能,就是点击列表中的每个位置,显示位置的小图标根据位置的改变而改变?/**
* 周边地理位置列表点击事件
lvLocNear.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView&?& adapterView, View view, int i, long l) {
adapter.setSelected(i);
adapter.notifyDataSetChanged();
PoiInfo ad = (PoiInfo) adapter.getItem(i);
u = MapStatusUpdateFactory.newLatLng(ad.location);
mBaiduMap.animateMapStatus(u);
if (!isLoc) {
mCurrentMarker.setPosition(ad.location);
markerA.setPosition(ad.location);
});好了,很简单有用的一个小功能,会给用户带来很好的体验效果。
专注培养IT技术人才
主营:PHP培训,JAVA培训,HTML5培训,UI培训,Linux培训,Python培训
说明写错了
为您推荐:
其他类似问题
百度地图的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
Android_GPS_定位课件.ppt 37页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
你可能关注的文档:
··········
··········
区域临近警告 区域临近警告 区域临近警告 区域临近警告 区域临近警告 Geocoding 介绍 Geocoding 介绍 Geocoding 介绍 Geocoder的替代 Geocoder的替代 JSON数据解析 JSON数据解析 JSON数据解析 JSON数据解析 JSON数据解析 JSON数据解析 总结 可以看到模拟器的DDMS中输出了错误信息:服务不可用。 目前这个问题还没有有效的解决方案。所以我们只能想其他的办法来实现这个功能。 好在Google还提供了另外一种方式来实现查询地址经纬度的功能 我们可以通过输入指定的地址将要查询的参数发送给某个WEB地址,就可以得到想要的地理信息数据。 打开浏览器输入地址http://maps.google.com/maps/api/geocode/json?address=shanghai&sensor=false 即可以得到一个JSON格式的数据文件。下载并且打开,可以看到其中包括了上海市地理信息数据,注意:如果查询出了多个结果,则以数组的形式记录在JSON数据中。 如果我们修改其中的address的值改为其他地址,即可以得到相应的地址地理信息,sensor=false表示请求该地址不是来自传感器的操作. 如果想得到XML格式的数据文件,只需要把JSON改成XML即可。 除了根据名称查询地理信息外,该地址还提供了其他的几种写法: http://maps.google.com/maps/api/geocode/json?latlng=39..3491970&sensor=false 根据经纬度查询地址 http://maps.google.com/maps/api/geocode/xml?address=Toledo&sensor=false&region=us 在指定的国家代号的区域中查找地理数据 region的值为国家代号,换成es将会查询西班牙的对应的该位置的信息
当我们获得了对应的位置的地理信息JSON数据后,就需要来解析了。首先分析JSON里面数据的格式。 Json数据 status results formatted_address address_components types 红字标识的是数组 types Long_name short_name status:数据状态 OK表示成功获得,ZERO_RESULTS 表示未找到数据 results:表示查找的结果,多个结果以数组元素方式表示 formatted_address:表示完整的地址名称 address_components:表示完整的地址中的某一个部分。比如中国-湖北-武汉包括三个地址部分组成。 types:该地址表示的类型 long_name 某部分地址的完整名 short_name 某部分地址的简称
利用前面所学的GSON知识和向WEB程序发送请求的知识,就可以通过发送请求的方式获得我们想要的位置的地理信息了。 //发送请求下载JSON public static String getJSONFromURL(String url){ String result = ""; HttpClient client = client = new DefaultHttpClient(null); HttpPost post = new HttpPost(url); try { //设置请求头的语言为中文简体 post.setHeader("accept-language", "zh-cn"); HttpResponse response = client.execute(post); HttpEntity entity = response.getEntity(); result = EntityUtils.toString(entity, "UTF-8"); } catch (Exception e) {
e.printStackTrace(); }
} //JSON数据的封装对象 public class GsonData {
public List } //Result对象 public class Result { public List address_ public G public String[] public String formatted_ } //Location对象 public class Location {
正在加载中,请稍后...真机测试 CLLocationManager 定位不准确
[问题点数:40分,结帖人zzxap]
真机测试 CLLocationManager 定位不准确
[问题点数:40分,结帖人zzxap]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2009年5月 .NET技术大版内专家分月排行榜第三
2012年2月 移动平台大版内专家分月排行榜第二2012年1月 移动平台大版内专家分月排行榜第二2011年5月 移动平台大版内专家分月排行榜第二2011年4月 移动平台大版内专家分月排行榜第二2009年1月 移动平台大版内专家分月排行榜第二
2011年12月 移动平台大版内专家分月排行榜第三2011年11月 移动平台大版内专家分月排行榜第三2011年9月 移动平台大版内专家分月排行榜第三2011年8月 移动平台大版内专家分月排行榜第三2010年3月 移动平台大版内专家分月排行榜第三2010年2月 移动平台大版内专家分月排行榜第三2009年4月 移动平台大版内专家分月排行榜第三2009年3月 硬件/嵌入开发大版内专家分月排行榜第三
匿名用户不能发表回复!|Access denied | www.programcreek.com used Cloudflare to restrict access
Please enable cookies.
What happened?
The owner of this website (www.programcreek.com) has banned your access based on your browser's signature (42b4d9d14dde2234-ua98).}

我要回帖

更多关于 new hadoop location 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信