❶ android中集成了百度地图 有经纬度的坐标怎样能实现定位
朋友:
网络地图没有输入经纬度进行查询的功能,
你要不下载一个google地球吧,先定位到某地,在图的下方就是经纬度 。
❷ 怎么在android百度地图通过经纬度来定位并且显示出地图位置
可以参考如下内容:
使用Android自带的LocationManager和Location获取位置的时候,经常会有获取的location为null的情况,并且操作起来也不是很方便,在这个Demo里我使用了网络地图API中的定位SDK,可以一次性获取当前位置经纬度以及详细地址信息,还可以获取周边POI信息,同时可以设定位置通知点,当到达某一位置时,发出通知信息等方式来告知用户。jar包下载以及官方文档请参照:网络定位SDK,前提是需要注册网络开发者账号。
下面来看看定位的基本原理,目前,定位SDK可以通过GPS、基站、Wifi信号进行定位。基本定位流程如下图所示,当应用程序向定位SDK发起定位请求时,定位SDK会根据当前的GPS、基站、Wifi信息生成相对应的定位依据。然后定位SDK会根据定位依据来进行定位。如果需要,定位SDK会向定位服务器发送网络请求。定位服务器会根据请求的定位依据推算出对应的坐标位置,然后根据用户的定制信息,生成定位结果返回给定位SDK。
❸ 高德地图,android开发中,怎么用经纬度来显示地图
首先创建工程,并在工程Build Path>Configure Build Path…>libraries 中选择“Add Externel JARs…”,选定
MapApi.jar,点击OK,这样就可以将高德地图Android API 库文件引入。然后在工程Build Path>Configure Build
Path…>Order and Export 中将引入的库文件MapApi.jar 选中,点击OK,这样您就可以在您的程序中使用高德地图API
了。
二、我们在不熟悉的情况下、先尽量多的添加此软件应用权限;所以在mainifest中添加如下代码;插入的位置在
<application的代码之前。
java代码
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
三、接着就要在res文件下的layout中添加界面布局了。其代码如下、你可以完全复制进去。
Java代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--添加文本输入框,查找地址-->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content" android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="经度"/>
<EditText android:layout_height="fill_parent"
android:layout_width="100px"
android:id="@+id/longitude"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="纬度"/>
<EditText android:layout_height="fill_parent"
android:layout_width="100px"
android:id="@+id/latitude"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查找"
android:id="@+id/button"/>
</LinearLayout>
<com.amap.mapapi.map.MapView android:id="@+id/mapView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:clickable="true"
/>
</LinearLayout>
四、最后就是软件的主程序部分了、里面需要的类和方法不多,主要以按钮的监听器和地图的界面实现为主
Java代码
public void onCreate(Bundle savedInstanceState) {
// this.setMapMode(MAP_MODE_VECTOR);//设置地图为矢量模式
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setBuiltInZoomControls(true); // 设置启用内置的缩放控件
mMapController = mMapView.getController(); // 得到mMapView
// 的控制权,可以用它控制和驱动平移和缩放
point = new GeoPoint((int) (39.982378 * 1E6), (int) (116.304923 * 1E6)); // 用给定的经纬度构造一个GeoPoint,单位是微度(度*
// 1E6)
// 按钮添加监听器
button_location = (Button) findViewById(R.id.location);
longitude = (EditText) findViewById(R.id.longitude);
latite = (EditText) findViewById(R.id.latitude);
locationListener = new OnClickListener() {
public void onClick(View e) {
if (e.equals(button_location)) {
// 得到文本输入框的中经纬 度坐标值
String latStr = longitude.getText().toString();
// 将得到的字符串转成数值
double lat = Integer.parseInt(latStr);
String lngStr = latite.getText().toString();
double lng = Integer.parseInt(lngStr);
//转成经纬度坐标
lat=lat*1E6;
lng=lng*1E6;
// 用给定的经纬度构造一个GeoPoint,单位是微度(度*1E6)
point = new GeoPoint((int) (lat), (int) (lng));
mMapController.setCenter(point); // 设置地图中心点
mMapController.setZoom(12); // 设置地图zoom 级别
// 添加地图覆盖物
// MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation(); // 判断是否发现位置提供者
mylocTest.enableCompass(); // 打开指南针
mMapView.getOverlays().add(mylocTest);// 添加定位覆盖物
}
}
};
// 按钮添加监听器
button_location.setOnClickListener(locationListener);
mMapController.setCenter(point); // 设置地图中心点
mMapController.setZoom(12); // 设置地图zoom 级别
// 添加地图覆盖物
mylocTest = new MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation(); // 判断是否发现位置提供者
mylocTest.enableCompass(); // 打开指南针
mMapView.getOverlays().add(mylocTest);// 添加定位覆盖物
}
//另外一个添加界面覆盖物的类:
public class MyLocationOverlayProxy extends com.amap.mapapi.map.MyLocationOverlay{
private Location mLocation;
protected final Paint mPaint = new Paint();
protected final Paint mCirclePaint = new Paint();
private Bitmap gps_marker=null;
private Point mMapCoords = new Point();
private final float gps_marker_CENTER_X;
private final float gps_marker_CENTER_Y;
private final LinkedList<Runnable> mRunOnFirstFix = new LinkedList<Runnable>();
public MyLocationOverlayProxy(amap amap, MapView mMapView) {
super(amap, mMapView);
gps_marker = ((BitmapDrawable) amap.getResources().getDrawable(
R.drawable.marker_gpsvalid)).getBitmap();
gps_marker_CENTER_X = gps_marker.getWidth() / 2 - 0.5f;
gps_marker_CENTER_Y= gps_marker.getHeight() / 2 - 0.5f;
}
public boolean runOnFirstFix(final Runnable runnable) {
if (mLocation != null) {
new Thread(runnable).start();
return true;
} else {
mRunOnFirstFix.addLast(runnable);
return false;
}
}
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
mLocation = location;
for(final Runnable runnable : mRunOnFirstFix) {
new Thread(runnable).start();
}
mRunOnFirstFix.clear();
super.onLocationChanged(location);
}
protected void drawMyLocation(Canvas canvas, MapView mapView, final Location mLocation,
GeoPoint point, long time) {
Projection pj=mapView.getProjection();
if (mLocation != null) {
mMapCoords=pj.toPixels(point, null);
final float radius = pj.metersToEquatorPixels(mLocation.getAccuracy());
this.mCirclePaint.setAntiAlias(true);
this.mCirclePaint.setARGB(35, 131, 182, 222);
this.mCirclePaint.setAlpha(50);
this.mCirclePaint.setStyle(Style.FILL);
canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, this.mCirclePaint);
this.mCirclePaint.setARGB(225, 131, 182, 222);
this.mCirclePaint.setAlpha(150);
this.mCirclePaint.setStyle(Style.STROKE);
canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, this.mCirclePaint);
canvas.drawBitmap(gps_marker, mMapCoords.x-gps_marker_CENTER_X, mMapCoords.y-gps_marker_CENTER_Y, this.mPaint);
}
}
}
❹ 跪求在线等,android 把图片做成地图 实现缩放移动功能,并且能根据GPS获取的经纬度,在图片上标注图标,
通过比例换算,对应到图片上。
❺ android系统 拍照片时 能不能记录用户的经纬度
大多数安卓手机拍摄照片是支持记录地理位置信息的,若自带相机没有此功能,可以借助第三方拍照软件来实现此功能,如相机360。
❻ android得到经纬度怎么获取位置
Android地图开发实际应用中,经常会通过地图定位判断手机用户是哪个城市的,然后根据城市的不同调取不同的数据,或者是地图定位之后,会在手机界面中显示用户的详细位置,如石家庄市中山北国商城。
那么这些信息如何获得? 详细研究过Android MapView的可能用到Geocoder这个对象。详细代码如下:[java] view plain
Geocoder geocoder=new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses=geocoder.getFromLocation(latitude, longitude, 1);
StringBuilder stringBuilder=new StringBuilder();
if(addresses.size()>0){
Address address=addresses.get(0);
for(int i=0;i<address.getMaxAddressLineIndex();i++){
stringBuilder.append(address.getAddressLine(i)).append("\n");
}
stringBuilder.append(address.getLocality()).append("_");
stringBuilder.append(address.getPostalCode()).append("_");
stringBuilder.append(address.getCountryCode()).append("_");
stringBuilder.append(address.getCountryName()).append("_");
System.out.println(stringBuilder.toString());
}
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(this, "报错", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
❼ android百度地图怎么查看指定地点的经纬度
❽ 怎么在android百度地图通过经纬度来定位并且显示出地图位置
1、设置AndroidManfest.xml权限ViewCode2、配置jar包3、初始化设置BMapManagerViewCodemapManager=newBMapManager(this);mapManager.init("",newMyMKGeneralListener());//设置通知间隔:iMaxSecond-最大通知间隔,单位:秒;iMinSecond-最小通知间隔,单位:秒mapManager.getLocationManager().setNotifyInternal(20,5);4、获取手机经纬度,并显示地址信息ViewCodemapManager.getLocationManager().requestLocationUpdates(newMyLocationListener());mapManager.start();在LocationListener中获取经纬度{@(Locationarg0){intjin=(int)(arg0.getLatitude()*1000000);intwei=(int)(arg0.getLongitude()*1000000);tv1.setText("经度:"+jin+",纬度:"+wei);MKSearchsearch=newMKSearch();search.init(mapManager,newMyMKSearchListener());search.reverseGeocode(newGeoPoint(jin,wei));}}在MKSearch接口中进行地址转化
❾ android中怎么获取经纬度
在Android应用程序中,可以使用LocationManager来获取移动设备所在的地理位置信息。看如下实例:新建android应用程序TestLocation。
1、activity_main.xml布局文件
[html] view plain
print?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/positionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
用于显示获取到的位置信息。
2、MainActivity.Java
[java] view plain
print?
package com.example.testlocation;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
private TextView postionView;
private LocationManager locationManager;
private String locationProvider;
@Override
protected void onCreate(Bundle savedInstanceState) {