googlemap学习
来源:互联网 发布:thinkpad 知乎 编辑:程序博客网 时间:2024/03/28 18:28
<!-- 获取得到的地图密匙 -->
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0EGaQ0LojZADsSw-E2Nh0NIYkPuTgNKFSmvHWsA"
/>
package my.yaner.googlemap;
import my.yaner.R;
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.widget.TextView;
/**
* google地图搜索应用启动类
* @author Administrator
* 通过调用andorid自带的API实现地域的查询
*/
public class GoogleMapStartActivity extends Activity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.googlemap);
init();
}
private void init() {
String serviceString = Context.LOCATION_SERVICE;
LocationManager locationManager = (LocationManager) getSystemService(serviceString);
String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider); //获取当前的位置信息
getLocationInfo(location);
locationManager.requestLocationUpdates(provider, 2000, 0, locationListener);
}
private void getLocationInfo(Location location) {
String latLongInfo;
TextView locationText = (TextView) findViewById(R.id.google_str_textview);
if(location != null){
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongInfo = "Lat: " + lat + " ,nLong: " + lng;
}else{
latLongInfo = "no location found";
}
locationText.setText("您当前所在的位置是:" + latLongInfo);
}
private LocationListener locationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
getLocationInfo(null);
}
@Override
public void onProviderDisabled(String provider) {
getLocationInfo(null);
}
@Override
public void onLocationChanged(Location location) {
getLocationInfo(location);
}
};
}
- googlemap学习
- googleMap学习资料网站
- googlemap
- GoogleMap
- GoogleMap
- android学习笔记之GoogleMap
- android 学习之---Android之GoogleMap(转)
- android学习笔记之GoogleMap 【转】
- 试用GoogleMap
- GoogleMap api
- googlemap(一)
- googlemap 使用
- googleMap api
- GoogleMap 导航
- Flex+GoogleMap
- GoogleMap记下:
- 【android学习之十六】——特色功能1:GoogleMap手机地图
- GoogleMap 封IP
- Multiple Buttons on a Navigation Bar
- 数据库同步工具: Red Gate Sql Compare
- JIT优化策略摘录
- oracle常用的时间格式转换
- 操作系统的有限缓冲区问题
- googlemap学习
- 【转】经济计量学软件包Eviews快速使用
- Windows 7的发展更加好
- uva10310
- C语言宏定义的用法
- 宏定义中“#”的问题
- ACE-6.0.0 编译安装使用
- Linux命令行下统计当前文件夹下的文件个数
- 虚拟磁带库真正能做的