如果您对支持两个GoogleMapAPI和V1和V2的最佳方法是什么?感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解支持两个GoogleMapAPI的各种细节,并对V1和V2的最佳方法是什么?
如果您对支持两个Google Map API和V1和V2的最佳方法是什么?感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解支持两个Google Map API的各种细节,并对V1和V2的最佳方法是什么?进行深入的分析,此外还有关于asp.net-web-api – 实现ASP.NET WebAPI版本控制的最佳方法是什么?、Google Map Android API V2中两个位置之间的旅行时间、Google Map Android API v2:GoogleMap为空、Google Map API V2密钥申请的实用技巧。
本文目录一览:- 支持两个Google Map API(V1和V2)的最佳方法是什么?(支持googleplay服务的双开)
- asp.net-web-api – 实现ASP.NET WebAPI版本控制的最佳方法是什么?
- Google Map Android API V2中两个位置之间的旅行时间
- Google Map Android API v2:GoogleMap为空
- Google Map API V2密钥申请
支持两个Google Map API(V1和V2)的最佳方法是什么?(支持googleplay服务的双开)
在我的应用程序中同时支持两个android map api的最佳方法是什么?
Google 发行了android google map api v2, 而 v1
仍然存在(并且对于较旧的手机效果更好)。
到目前为止,我看到了两个场景。
1)两个apk:每个api一个apk
我可以使用中提供的多个apk功能google play
。
- 我该如何区分
google play
?对opengl的支持?
这种情况意味着每次我要构建项目时,都必须复制/粘贴一些文件,更新其他文件,这可能很麻烦。
除非我使用量身定制的构建过程(使用ant或maven)。
- 有什么建议吗?
2)一
可以使用if/else
语句来实现这一点,在manifest
文件中包括 两个 api 的声明。
- 有人尝试过吗?
注意:Google会针对较旧的手机进行映射
首先,新的v2 api基于矢量,在CPU / GPU上较重(v1 api使用位图图块)。
其次,新的v2 API需要opengl 2.0。据说所有运行的Android设备froyo
或更高版本都支持该功能。
不幸的是,事实并非如此。
例如,google play / markets无法识别出一种古老的HTC魔术运行姜饼(在自定义rom上)以支持opengl 2.0。
也许还有更多…
答案1
小编典典可以使用if / else语句(在清单文件中包括两个api的声明)来实现这一目的。
好吧,清单中不能包含“ if / else语句”。
从我的角度来看,基本上有三种方案:
- 设备没有OpenGL ES 2.0或更高版本
- 该设备确实具有OpenGL ES 2.0或更高版本,但目前没有Google Play服务(可能是因为它没有Play商店)
- 该设备具有OpenGL ES 2.0或更高版本,并具有Google Play服务
正如您在对另一个答案的评论中所指出的那样,我的方案#1无法与其他两个方案共存,仅仅是因为您 必须 具有<uses-feature>
调用OpenGL
ES 2.0 的元素。而且,由于Play商店不支持基于OpenGL ES
API级别的多个APK文件,因此对于同一Play商店列表,您无法同时支持方案1和其他两个方案。您必须在Play商店中拥有两个完全独立的应用程序:一个仅使用可在所有Android设备上运行的Maps
V1,另一个使用Maps V2(在我的方案#2中使用Maps V1)在OpenGL ES 2.0+设备上运行。
另外,请记住,在2013年3月3日之后,将不再提供Maps V1
API密钥。在那之后进行Maps V1开发会变得越来越危险,因为如果开发环境出现问题,您将无法获取新的API密钥。
基本上,这意味着与以前相比,依赖Google Maps开发应用程序的方式新颖有趣。即使您说要彻底放弃Maps
V1,也存在属于我的方案2的设备。希望不会有很多,尽管肯定有一些(例如,靠近我的HTC EVO 3G)。不应有运行Android 3.0及更高版本的设备-
我很确定OpenGL ES 2.0是Android 3.0的硬性要求,并且Play商店应该在所有这些设备上(因此, Google
Play服务应可用于所有服务)。
坦白说,对于某些开发人员来说,最好的答案是完全放弃Google的地图,并使用OpenStreetMap或其他具有更高稳定性的东西(如果他们想支持Android
1.x / 2.x设备)。
asp.net-web-api – 实现ASP.NET WebAPI版本控制的最佳方法是什么?
我正在从头开始构建一个API,我想确保它将来会优雅地发布.我正在设想像mysite.com/api/v2 / …
我看到的一种方法是为每个API版本创建一个单独的项目(Web应用程序).但也许有更好的方法来做到这一点?
谢谢你的想法.
解决方法
尽管可以,您不需要创建一个全新的项目.您将面临单个项目的问题是名称会发生冲突:
/api/v1.0/Car/123
和
/api/v2.0/Car/123
两者都会指向CarController,而你只能拥有其中一个.解决方案是实现您自己的IHttpControllerSelector并注册DependencyResolver.此实现将查看版本号,并可能根据命名空间查找类型.
UPDATE
我不打算在这里开始一个REST争议.但正如@DarrelMiller指出的那样,这是对同一主题的较早讨论,这阻碍了我建议的方法:
How to version REST URIs
我个人认为URL版本化是要走的路.
Google Map Android API V2中两个位置之间的旅行时间
如何在Google Map Android API
V2中显示两个位置之间的旅行时间,在我的程序中,我使用JSONParse显示行驶距离,但是我无法显示显示旅行时间,我制作了此示例程序:DirectionActivity.java
public class DirectionActivity extends FragmentActivity implements OnMyLocationChangeListener{
private LatLng start;
private LatLng end;
private String nama;
private final String URL = "http://maps.googleapis.com/maps/api/directions/json?";
private GoogleMap map;
private JSONHelper json;
private ProgressDialog pDialog;
private List<LatLng> listDirections;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction);
json = new JSONHelper();
setupMapIfNeeded();
Bundle b = getIntent().getExtras();
if (b != null)
{
start = new LatLng(b.getDouble(MainActivity.KEY_LAT_ASAL),b.getDouble(MainActivity.KEY_LNG_ASAL));
end = new LatLng(b.getDouble(MainActivity.KEY_LAT_TUJUAN),b.getDouble(MainActivity.KEY_LNG_TUJUAN));
nama = b.getString(MainActivity.KEY_NAMA);
}
new AsyncTaskDirection().execute();
}
private void setupMapIfNeeded()
{
if (map == null)
{
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager
.findFragmentById(R.id.mapsdirections);
map = supportMapFragment.getMap();
if (map != null)
{
setupMap();
}
}
}
private void setupMap()
{
map.setMyLocationEnabled(true);
map.setOnMyLocationChangeListener(this);
moveToMyLocation();
}
private void moveToMyLocation()
{
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria,false));
if (location != null)
{
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(location.getLatitude(),location.getLongitude()),13));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main,menu);
return true;
}
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
int resCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (resCode != ConnectionResult.SUCCESS)
{
GooglePlayServicesUtil.getErrorDialog(resCode,this,1);
}
}
private class AsyncTaskDirection extends AsyncTask<Void,Void,Void>
{
@Override
protected Void doInBackground(Void... params)
{
String uri = URL
+ "origin=" + start.latitude + "," + start.longitude
+ "&destination=" + end.latitude + "," + end.longitude
+ "&sensor=true&units=metric";
JSONObject jObject = json.getJSONFromURL(uri);
listDirections = json.getDirection(jObject);
return null;
}
@Override
protected void onPreExecute()
{
// TODO Auto-generated method stub
super.onPreExecute();
pDialog = new ProgressDialog(DirectionActivity.this);
pDialog.setMessage("Loading....");
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected void onPostExecute(Void result)
{
// TODO Auto-generated method stub
super.onPostExecute(result);
pDialog.dismiss();
gambarDirection();
}
}
public void gambarDirection()
{
PolylineOptions line = new PolylineOptions().width(3).color(Color.BLUE);
for (int i = 0; i < listDirections.size(); i++)
{
line.add(listDirections.get(i));
}
map.addPolyline(line);
// tambah marker di posisi end
map.addMarker(new MarkerOptions()
.position(end)
.title(nama));
}
@Override
public void onMyLocationChange(Location location)
{
Toast.makeText(this,"Lokasi berubah ke " + location.getLatitude() + "," + location.getLongitude(),Toast.LENGTH_SHORT).show();
}
}
JSONHelper.java
public class JSONHelper
{
private InputStream is = null;
private JSONObject jsonObject = null;
private String json = "";
private final String TAG_TEMPATMAKAN = "tempatmakan";
private final String TAG_ID = "id";
private final String TAG_NAMA = "nama";
private final String TAG_ALAMAT = "alamat";
private final String TAG_LAT = "lat";
private final String TAG_LNG = "lng";
private final String TAG_ROUTES = "routes";
private final String TAG_LEGS = "legs";
private final String TAG_STEPS = "steps";
private final String TAG_POLYLINE = "polyline";
private final String TAG_POINTS = "points";
private final String TAG_START = "start_location";
private final String TAG_END = "end_location";
public JSONObject getJSONFromURL(String url)
{
try
{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
} catch (ClientProtocolException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(
is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e)
{
// TODO: handle exception
}
try
{
jsonObject = new JSONObject(json);
} catch (JSONException e)
{
// TODO: handle exception
}
return jsonObject;
}
public ArrayList<TempatMakan> getTempatMakanAll(JSONObject jobj)
{
ArrayList<TempatMakan> listTempatMakan = new ArrayList<TempatMakan>();
try
{
JSONArray arrayTempatMakan = jobj.getJSONArray(TAG_TEMPATMAKAN);
for (int i = 0; i < arrayTempatMakan.length(); i++)
{
JSONObject jobject = arrayTempatMakan.getJSONObject(i);
Log.d("log","muter ke " + i);
listTempatMakan.add(new TempatMakan(jobject.getInt(TAG_ID),jobject.getString(TAG_NAMA),jobject
.getString(TAG_ALAMAT),jobject
.getDouble(TAG_LAT),jobject.getDouble(TAG_LNG)));
}
} catch (JSONException e)
{
e.printStackTrace();
}
return listTempatMakan;
}
/*
* Untuk decode Polyline
*
* @params String
*
* @return List<LatLng>
*/
private List<LatLng> decodePoly(String encoded)
{
List<LatLng> poly = new ArrayList<LatLng>();
int index = 0,len = encoded.length();
int lat = 0,lng = 0;
while (index < len)
{
int b,shift = 0,result = 0;
do
{
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do
{
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng position = new LatLng((double) lat / 1E5,(double) lng / 1E5);
poly.add(position);
}
return poly;
}
/*
* Untuk mendapatkan direction
*
* @params JSONObject
*
* @return List<LatLng>
*/
public List<LatLng> getDirection(JSONObject jObj)
{
List<LatLng> directions = new ArrayList<LatLng>();
try
{
JSONObject objRoute = jObj.getJSONArray(TAG_ROUTES).getJSONObject(0);
JSONObject objLegs = objRoute.getJSONArray(TAG_LEGS).getJSONObject(0);
JSONArray arraySteps = objLegs.getJSONArray(TAG_STEPS);
for (int wi2t = 0; wi2t < arraySteps.length(); wi2t++)
{
JSONObject step = arraySteps.getJSONObject(wi2t);
JSONObject objStart = step.getJSONObject(TAG_START);
JSONObject objEnd = step.getJSONObject(TAG_END);
double latStart = objStart.getDouble(TAG_LAT);
double lngStart = objStart.getDouble(TAG_LNG);
directions.add(new LatLng(latStart,lngStart));
JSONObject poly = step.getJSONObject(TAG_POLYLINE);
String encodedPoly = poly.getString(TAG_POINTS);
List<LatLng> decodedPoly = decodePoly(encodedPoly);
for (int eka = 0; eka < decodedPoly.size(); eka++)
{
directions.add(new LatLng(decodedPoly.get(eka).latitude,decodedPoly.get(eka).longitude));
}
double latEnd = objEnd.getDouble(TAG_LAT);
double lngEnd = objEnd.getDouble(TAG_LNG);
directions.add(new LatLng(latEnd,lngEnd));
}
} catch (JSONException e)
{
// TODO: handle exception
}
return directions;
}
}
MainActivity.java
public class MainActivity extends FragmentActivity implements OnInfoWindowClickListener
{
private GoogleMap map;
private JSONHelper json;
private ProgressDialog pDialog;
private Button btnGetDirection;
private List<TempatMakan> listTempatMakan;
private final String URL_API = "http://lhocation1203.hostzi.com/dataapi/tempatmakan.php";
public static final String KEY_NAMA = "nama";
public static final String KEY_ALAMAT = "alamat";
public static final String KEY_LAT_TUJUAN = "lat_tujuan";
public static final String KEY_LNG_TUJUAN = "lng_tujuan";
public static final String KEY_LAT_ASAL = "lat_asal";
public static final String KEY_LNG_ASAL = "lng_asal";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
json = new JSONHelper();
new AsynTaskMain().execute();
setupMapIfNeeded();
}
private void setupMapIfNeeded()
{
if (map == null)
{
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.maps);
map = supportMapFragment.getMap();
if (map != null)
{
setupMap();
}
}
}
private void setupMap()
{
map.setMyLocationEnabled(true);
map.setOnInfoWindowClickListener(this);
moveToMyLocation();
}
private void moveToMyLocation()
{
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria,menu);
return true;
}
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
int resCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (resCode != ConnectionResult.SUCCESS)
{
GooglePlayServicesUtil.getErrorDialog(resCode,1);
}
}
private class AsynTaskMain extends AsyncTask<Void,Void>
{
@Override
protected void onPostExecute(Void result)
{
// TODO Auto-generated method stub
pDialog.dismiss();
runOnUiThread(new Runnable()
{
@Override
public void run()
{
// TODO Auto-generated method stub
for (int i = 0; i < listTempatMakan.size(); i++)
{
map.addMarker(new MarkerOptions()
.position(new LatLng(listTempatMakan.get(i).getLat(),listTempatMakan.get(i).getLng()))
.title(listTempatMakan.get(i).getNama())
.snippet(listTempatMakan.get(i).getAlamat()));
}
}
});
super.onPostExecute(result);
}
@Override
protected void onPreExecute()
{
// TODO Auto-generated method stub
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading....");
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected Void doInBackground(Void... params)
{
// TODO Auto-generated method stub
JSONObject jObject = json.getJSONFromURL(URL_API);
listTempatMakan = json.getTempatMakanAll(jObject);
return null;
}
}
@Override
public void onInfoWindowClick(Marker marker)
{
// marker id -> m0,m1,m2 dst..
String id = marker.getId();
id = id.substring(1);
LatLng myLocation = new LatLng(map.getMyLocation().getLatitude(),map.getMyLocation().getLongitude());
if (myLocation != null)
{
Bundle bundle = new Bundle();
bundle.putString(KEY_NAMA,listTempatMakan.get(Integer.parseInt(id)).getNama());
bundle.putString(KEY_ALAMAT,listTempatMakan.get(Integer.parseInt(id)).getAlamat());
bundle.putDouble(KEY_LAT_TUJUAN,marker.getPosition().latitude);
bundle.putDouble(KEY_LNG_TUJUAN,marker.getPosition().longitude);
bundle.putDouble(KEY_LAT_ASAL,myLocation.latitude);
bundle.putDouble(KEY_LNG_ASAL,myLocation.longitude);
Intent i = new Intent(MainActivity.this,InfoTempatMakanActivity.class);
i.putExtras(bundle);
startActivity(i);
} else
{
Toast.makeText(this,"Tidak dapat menemukan lokasi anda ",Toast.LENGTH_LONG).show();
}
}
}
InfoTempatMakanActivity.java
public class InfoTempatMakanActivity extends Activity implements OnClickListener
{
private TextView tvNama;
private TextView tvAlamat;
private Button btnGetDirection;
private LatLng lokasiTujuan;
private LatLng lokasiAwal;
private String nama;
private String alamat;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_info_tempat_makan);
initialize();
Bundle bundle = getIntent().getExtras();
if (bundle != null)
{
nama = bundle.getString(MainActivity.KEY_NAMA);
alamat = bundle.getString(MainActivity.KEY_ALAMAT);
lokasiTujuan = new LatLng(bundle.getDouble(MainActivity.KEY_LAT_TUJUAN),bundle.getDouble(MainActivity.KEY_LNG_TUJUAN));
lokasiAwal = new LatLng(bundle.getDouble(MainActivity.KEY_LAT_ASAL),bundle.getDouble(MainActivity.KEY_LNG_ASAL));
}
setTeksView();
}
private void setTeksView()
{
tvNama.setText(nama);
tvAlamat.setText(alamat);
}
private void initialize()
{
tvAlamat = (TextView) findViewById(R.id.alamatTempatMakan);
tvNama = (TextView) findViewById(R.id.namaTempatMakan);
btnGetDirection = (Button) findViewById(R.id.btnDirection);
btnGetDirection.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
Bundle bundle = new Bundle();
bundle.putDouble(MainActivity.KEY_LAT_ASAL,lokasiAwal.latitude);
bundle.putDouble(MainActivity.KEY_LNG_ASAL,lokasiAwal.longitude);
bundle.putDouble(MainActivity.KEY_LAT_TUJUAN,lokasiTujuan.latitude);
bundle.putDouble(MainActivity.KEY_LNG_TUJUAN,lokasiTujuan.longitude);
bundle.putString(MainActivity.KEY_NAMA,nama);
Intent intent = new Intent(this,DirectionActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
}
TempatMakan.java
public class TempatMakan
{
private int id;
private String nama;
private String alamat;
private double lat;
private double lng;
public TempatMakan()
{
// TODO Auto-generated constructor stub
}
public TempatMakan(int id,String nama,String alamat,double lat,double lng)
{
super();
this.id = id;
this.nama = nama;
this.alamat = alamat;
this.lat = lat;
this.lng = lng;
}
public String getNama()
{
return nama;
}
public void setNama(String nama)
{
this.nama = nama;
}
public String getAlamat()
{
return alamat;
}
public void setAlamat(String alamat)
{
this.alamat = alamat;
}
public double getLat()
{
return lat;
}
public void setLat(double lat)
{
this.lat = lat;
}
public double getLng()
{
return lng;
}
public void setLng(double lng)
{
this.lng = lng;
}
}
Google Map Android API v2:GoogleMap为空
我正在尝试使用MapView类进行GoogleMap显示,没有运气,因为大多数代码示例都使用了我不想要的MapFragment.
我使用的是Google Maps Android API v2.
起初,只是为了测试here from Google’s example,我设法得到了典型的法线贴图来显示.
public class POnlineMapView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.online_map_activity);
}
}
上面的代码完美地运行,表明一切都已正确设置.
我现在正在尝试使用MapView类来操作显示设置,例如中心点,但似乎我每次尝试获取GoogleMap对象时都会获得一个null对象.为什么会这样?
public class POnlineMapView extends Activity {
private MapView myMapView;
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
myMapView = new MapView(getApplicationContext());
Bundle b = getIntent().getExtras();
double longitude = b.getDouble("longitude");
double latitude = b.getDouble("latitude");
setContentView(R.layout.online_map_activity);
map = myMapView.getMap();
CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(latitude,longitude));
CameraUpdate zoom=CameraUpdateFactory.zoomTo(17);
map.moveCamera(center); //this gives a NullPointerException, probably due to the myMapView.getMap() method?
map.animateCamera(zoom);
}
}
解决方法:
检查是否已安装(并更新)Google Play服务
见Google Maps Android API v2 throws GooglePlayServicesNotAvailableException, out of date, SupportMapFragment.getMap() returns null
另请阅读https://developers.google.com/maps/documentation/android/map(验证地图可用性部分)
Google Map API V2密钥申请
之前用的都是v1,用的是MapView,好吧,只能认命了。废话不再多说,开始android 的Google Maps Android API v2吧 之前参考了http://www.cnblogs.com/mengdd/archive/2013/01/01/2841390.html可是没有走通 Google Maps Android API v2的参考文档 https://deve
之前用的都是v1,用的是MapView,好吧,只能认命了。废话不再多说,开始android 的Google Maps Android API v2吧
之前参考了http://www.cnblogs.com/mengdd/archive/2013/01/01/2841390.html 可是没有走通
Google Maps Android API v2的参考文档
https://developers.google.com/maps/documentation/android/
好了 开始了 Getting Started
1.首先安装Google Play services SDK
打开Eclipse -> Window -> Android SDK Manager
我们还需要这东西,Google Play services(http://www.androidpolice.com/2012/09/26/google-play-services-can-now-be-installed-manually-from-the-play-store/)安装到你的手机上吧
2.获取API key
终于到获取API key 了,v2到底有什么不同呢?
想一想我们v1的时候API key是怎么申请的,怎么用的呢,是MD5,是Mapview
v2做了什么修改呢 是SHA1,当然他也不在需要Mapview了,那我们要API key有什么用呢 下面你就知道了
获取Maps API key需要两样东西:应用的signing certificate和它的package name。
获取这个key之后,把它加在应用程序的AndroidManifest.xml文件里即可。
获取数字证书(digital certificate)信息
数字证书有Debug和Release两种,下面主要说Debug的。
你只需要在你的命令行里照着这个操作就好了
我用的是Mac 所以
我的乱码了 不过没关系 我们需要的是SHA1(别忘了复制下来备用哦)
这难道是API key?不是的,下面才是我们需要的
在浏览器中 打开Google APIs Console(https://code.google.com/apis/console/)
用Gmail的账户登录,如果是第一次的话,需要创建项目,默认情况会创建一个叫做API Project的项目。
点击进入API Access
刚刚的SHA1还在吧。。
照着这个Example 的格式: SHA1;包名
是不是有了API key.
再点击进入Services
3.创建我们的自己项目应用程序
准备工作都做完了 现在开始做我们自己的项目
注意包名应该和申请key时候的包名一致
一.打开AndroidManifest.xml文件
我想下面你们可以自己看api自己做的:
1.在下添加
<span><span><span><span> </span><span>android:name</span><span>=</span><span>"com.google.android.maps.v2.API_KEY"</span><span> </span><span>android:value</span><span>=</span><span>"your_api_key"</span><span>/></span></span></span></span>
注意your_api_key置换成自己申请的API Key。
2.添加权限
<span><span><span>注意将com.example.mapdemo替换成你的包名 </span></span></span>
<span><span><span>android:name</span><span>=</span><span>"android.permission.INTERNET"</span><span>/></span><span>android:name</span><span>=</span><span>"android.permission.WRITE_EXTERNAL_STORAGE"</span><span>/></span><span>android:name</span><span>=</span><span>"com.google.android.providers.gsf.permission.READ_GSERVICES"</span><span>/></span><span>android:name</span><span>=</span><span>"android.permission.ACCESS_COARSE_LOCATION"</span><span>/></span><span>android:name</span><span>=</span><span>"android.permission.ACCESS_FINE_LOCATION"</span><span>/> </span></span></span>
3.下添加
<span><span><span><span> </span><span>android:glEsVersion</span><span>=</span><span>"0x00020000"</span><span> </span><span>android:required</span><span>=</span><span>"true"</span><span>/></span></span></span></span>
4.保存
我们今天的关于支持两个Google Map API和V1和V2的最佳方法是什么?的分享就到这里,谢谢您的阅读,如果想了解更多关于asp.net-web-api – 实现ASP.NET WebAPI版本控制的最佳方法是什么?、Google Map Android API V2中两个位置之间的旅行时间、Google Map Android API v2:GoogleMap为空、Google Map API V2密钥申请的相关信息,可以在本站进行搜索。
本文标签: