Android Map新用法:MapFragment应用

MapView ,MapActivity 这种的局限在于,必须要继承MapActivity,否则无法使用MapView,但是,MapFragment 这种的局限在于,必须要安装Google Play Service ,也就是说必须是原生rom。而且sdk要在12以上

1.MapView ,MapActivity 这种的局限在于,必须要继承MapActivity,否则无法使用MapView。纠结就在于此。但是,最新官网上已经弃用了这糟粕的MapActivity。
Version
1 of the Google Maps Android API as been officially deprecated as of
December 3rd, 2012. This means that from March 3rd, 2013 you will no
longer be able to request an API key for this version. No new features
will be added to Google Maps Android API v1. However, apps using v1 will
continue to work on devices. Existing and new developers are encouraged
to use Google Maps Android API v2.
2.MapFragment 这种的局限在于,必须要安装Google Play Service ,也就是说必须是原生rom。而且sdk要在12以上。我蛋疼了。
3.WebView 貌似很轻松的集成进来,但没有实践就木有发言权。
第一种方式我先略过了。大家都知道。说第二种,第三种会了再补上
MapFragment是刚出的google官方包,要集成进来还是挺麻烦的。官网链接 https://developers.google.com/maps/documentation/android/start

先要到google conlose 添加api access权限,拿到apikey,创建一个project
,然后到services里把Google Maps Android API v2打开,再到api
access里把你的project的keystore的SHA1和包名填进去,拿到唯一的api key
打开sdk
manager--在Extras里把Android Support Libaray 和 Google Play
Services都安装,lib和samples都在sdk_path/extra/google/google_play_services下。导
入../lib_project作为自己项目的libaray
这一步完了之后在manifest.xml文件里添加权限和api key。代码如下

<permission
android:name="com.example.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/> 

com.example替换成自己project的package

<uses-permission android:name="com.example.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!--My Location-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!--Maps API needs OpenGL ES2.0.-->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/> 

放在application声明里

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="appkey"/> 

在layout xml里加入MapFragment声明

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/> 
时间: 2024-08-30 13:15:27

Android Map新用法:MapFragment应用的相关文章

android hander 线程用法

@Override public void onClick(View v) { lsh = "576"; startdate = setstart_date.getText().toString(); enddate = setend_date.getText().toString(); btnLoginContext = v.getContext(); HandlerThread handlerThread = new HandlerThread("handlerThrea

Android WIFI 简单用法

随着Wifi的普及,在开发App的时候对wifi的考虑越来越多了.例如程序的升级在wifi下可以省很多流量,在通信软件中的视频通话.可以实现高画质的传输等等,Android提供了WifiManager类来帮助开发者们管理Wifi.下面就简单来说一下WifiManager的简单用法把. 权限: 为了使用WfiManager 我们需要在Androidmanifest.xml 加入权限: //本例中使用了前两个.具体请按照需要添加权限. <uses-permission android:name=&quo

Google I/O 2014 大会总结 Android开发新方向

昨天晚上,Google I/O 2014大会召开,会上主要展示了以下几个部分的创新内容: Android L 操作系统 首先是界面,谷歌重新设计了一套 UI 规范,并称之为"Material Design",这种语言风格从一些人们常用的物品中汲取灵感,比如纸张和墨水的晕染,让屏幕空间得到最佳应用,提供尽量多的资讯信息,并且可以在智能手机.平板或桌面上提供统一的设计界面. 具体风格上看,Material Design 大量使用了圆形和圆角的扁平化设计,更多的操作是通过滑动完成而不是点击.

Android之Fragment用法

本文翻译自Android developer网站上面,原文参考:Building a Dynamic UI with Fragments 当我们需要动态的多界面切换的时候,就需要将UI元素和Activity融合成一个模块.在2.3中我们一般通过各种Activity中进行跳转来实现多界面的跳转和单个界面动态改变.在4.0或以上系统中就可以使用新的特性来方便的达到这个效果--Fragment类.Fragment类似一个嵌套Activity,可以定义自己的layout和自己的生命周期. 多个Fragm

Android之Adapter用法总结

http://blog.csdn.net/fznpcy/article/details/8658155 Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(List View,Grid View)等地方都需要用到Adapter.如下图直观的表达了Data.Adapter.View三者的关系: Android中所有的Adapter一览: 由图可以看到在Android中与Adapter有关

Android之Adapter用法总结(转)

Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(List View,Grid View)等地方都需要用到Adapter.如下图直观的表达了Data.Adapter.View三者的关系: Android中所有的Adapter一览: 由图可以看到在Android中与Adapter有关的所有接口.类的完整层级图.在我们使用过程中可以根据自己的需求实现接口或者继承类进行一定的扩展.比较常用

Android Studio编译运行Fresco Sample。Android缓存新境界。 (a problem occurred start process &#39;command &#39;ndk-build&#39;&#39;)

今天闲逛知乎,偶遇一篇“Android应用开发难点”,作为安卓程序猿,本能点进去,想看看究竟能有什么难点自己不知道的(夜郎自大..面壁中). 插件化,H5容器优化,网络.图片缓存..感觉都还好.直到看到“Fresco出来之前,你是不是觉得图片缓存已经到头了?” Fresco究竟是何方神圣!! 询问度娘得知,2015.3.27日之前就已经发布了(度娘的结果最早是3.27).通过查看GitHub: Version 0.1.0  tyronen released this 16 days ago · 

Android ListView的用法

ListView是比较常用的控件,但一直都觉得创建ListView步骤有点繁琐,故在此总结一下,方便查阅. 程序效果是实现一个ListView,ListView里面有标题,内容和图片,并加入点击和长按响应. 首先在xml里面定义一个ListView Xml代码   <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01&quo

forEach、for+i、map的用法及区别

  array.forEach(callback[, thisObject]); 下面是参数的详细信息: 1. callback : 函数测试数组的每个元素. 2.thisObject : 对象作为该执行回调时使用. forEach是ECMA5中Array新方法中最基本的一个,就是遍历,循环. Array在ES5新增的方法中,参数都是function类型,默认有传参,forEach方法中的function回调支持3个参数,第1个是遍历的数组内容:第2个是对应的数组索引,第3个是数组本身. [].