好吧,这是我用这个例子做的
通过命令生成密钥
$ keytool -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android
复制粘贴在Google API控制台+我的包名称中的SHA1总和:
总和; com.my.package
在Google API控制台的同一项目中启用了Google Map API v2
将其复制到元数据中的Manifest应用程序.
通过SDK管理器下载并导入google-play-services_lib项目并将其作为库项目引用.以及ActionBarSherlock.
在启动之前,我确保GooglePlayServices可用.
表现:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.my.package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.my.package.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Run Code Online (Sandbox Code Playgroud)
应用:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="debug_key"/>
Run Code Online (Sandbox Code Playgroud)
还添加了proguard的东西,但我现在没有混淆.
DrugstoresMapActivity扩展了SherlockFragmentActivity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map_fragment"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
project.properties
target=android-17
android.library.reference.1=../google-play-services_lib
android.library.reference.2=../ActionBarSherlock
Run Code Online (Sandbox Code Playgroud)
ActionBarSherlock在libs中有android-support-v4,如果重要的话,不是主项目.
StartupActivity确保只有可用的服务才会启动DrugstoresMapActivity
private void attempt() { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用为Android提供的最新Map API 2.0.我正在使用支持库,因为我想支持Android 2.2.以下是我的代码:
主要活动类
public class MainActivity extends FragmentActivity {
public FragmentManager fManager ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fManager = getSupportFragmentManager();
Button showMapButton = (Button) findViewById(R.id.showMapButton);
showMapButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loadMapFragment();
}
});
}
private void loadMapFragment() {
MapPageFragment plotterFragment = new MapPageFragment();
FragmentTransaction ft = fManager.beginTransaction();
ft.replace(R.id.allFragmentsFrameLayout, plotterFragment);
ft.addToBackStack(null);
ft.commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
主活动布局文件
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" …Run Code Online (Sandbox Code Playgroud) maps android google-maps-api-2 android-fragments supportmapfragment
我正在使用Google Map V2 API来制作地图.我已经在libs文件夹中复制了google-play-services.jar,并在eclipse的构建路径中进行了设置.
因为我添加了logcat,我得到了异常.
请帮忙解决这个问题.
home_map_view.xml
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_marginBottom="60dp"/>
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml中
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<permission
android:name="com.example.app.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.example.app.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="KEY"/>
<activity android:name=".MainActivity" android:label="@string/app_name" android:clearTaskOnLaunch="true"
android:configChanges="orientation" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".HomeMapView" android:label="@string/title_home" android:configChanges="orientation" android:launchMode="singleTop" />
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
HomeMapView.java
public class HomeMapView extends …Run Code Online (Sandbox Code Playgroud) 我正在开发Android应用程序并使用GoogleMaps API v2.此应用程序到目前为止工作,但我想在地图中搜索路径:
截图:

我的代码:
Position_mark = new LatLng(35.7008, 51.437);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(Position_mark, 15));
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
map.setOnMapClickListener(this);
map.setOnMapLongClickListener(this);
map.setOnMarkerDragListener(this);
Run Code Online (Sandbox Code Playgroud)
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Used to put dark icons on light action bar
mGoItem = menu.add(0, Delete_ITEM_ID, 0, null);
mGoItem.setIcon(R.drawable.ic_launcher)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
SearchView searchView =
new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search for Places…");
searchView.setIconified(false);
menu.add("Search")
.setIcon(R.drawable.abs__ic_search)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String newText) {
return true;
}
/**
* Called when the query text is changed by the user.
* …Run Code Online (Sandbox Code Playgroud) android google-maps geolocation google-maps-markers google-maps-api-2
我想制作一个程序来计算一些地方到我当前位置之间的距离,但是我的googleMap.getMyLocation(); 不能正常工作.
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setCompassEnabled(false);
mylocation = googleMap.getMyLocation();
direction = new GMapV2Direction();
LatLng from, to;
from = new LatLng(-7.26071409, 112.80674726);
for(int i=0; i<lat.length; i++){
to = new LatLng(lat[i], lon[i]);
doc = direksi.getDocument(from, to, GMapV2Direction.MODE_DRIVING);
distance[i] = (double)direction.getDistanceValue(doc) / 1000;
}
Run Code Online (Sandbox Code Playgroud)
我保存了lat []和lon []中某些地方的纬度和经度.LatLng'from'是mylocation,'to'是我的目的地.我改变时出现问题
from = new LatLng(-7.26071409, 112.80674726);
to
from = new LatLng(mylocation.getLatitude(), mylocation.getLongitude());
Run Code Online (Sandbox Code Playgroud)
我想在不打开googlemaps的情况下进行计算.当我将地图按钮作为弹出窗口触摸时,将显示谷歌地图.所以计算将在不打开googlemap的情况下进行
请帮我
我正在尝试使用库中的geocode函数来获取特定位置的坐标.到目前为止,我能够正常使用该功能.ggmapsR
我遇到的问题是我希望将每日限制从2,500增加到100,000.官方Google 文档
说,如果您在项目上启用结算,这很容易实现,我很乐意这样做.继续此过程后,Google Developers Console将为您提供个性化的API密钥.
但是,该geocode功能无法选择放入此个性化API密钥.相反,它要求client(业务用户的客户端ID)和signature(业务用户的签名),这是Google Maps API for Work客户可以访问API的方式.我知道这也是一个选项,但这似乎是一个非常大的用例,因为Google Maps API for Work似乎是为大型企业帐户设计的:
根据年度合同购买,每24小时的每日配额为100,000个请求.
所以我的问题归结为:我可以使用库中的geocode函数来ping Google Maps Geocoding API吗?ggmapsR
如何以编程方式缓存/下载google map v2 tile?有可能吗?
Bcos根据这个prntscr.com/3cyiqf它是不可能的,但是我已经看到这个链接 TileProvider使用本地磁贴 我认为如果Android提供TileProvider类来加载/使用资产中的磁贴比它应该是可用于缓存/下载的东西以编程方式/运行时
我的实际要求是:
如果用户当时与互联网连接,他可以下载/缓存特定区域的磁贴,或者他可以在电话屏幕中下载/缓存可见地图,并且当他下线时,下载的地图应该是可见的.
到目前为止我做了什么:
我见过OSMDROID lib它们提供了非常好的功能,但问题是我只想使用Google Map V2
我已经检查过静态地图API,我也创建了一个用于下载图块的演示,但是他们返回了一个具有指定缩放级别的图像,所以在这种情况下,如果我使用静态地图api,用户只能看到1级别的地图,他们就不能能够放大/缩小所以不好.
结论:
我想知道Google Map V2是否提供了以编程方式/运行时下载/缓存地图图块的任何工具?
编辑
我可以使用谷歌地图引擎吗?
android offline-caching google-maps-api-2 osmdroid google-maps-engine
我想touchListener在使用Google Maps V2 Android API显示的折线上实现一个.
缩放级别:
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(lat_Lng, 5);
我尝试了以下折线触摸代码:
boolean onpoly = false;
for (Polyline polyline : mPolylines) {
for (LatLng polyCoords : polyline.getPoints()) {
float[] results = new float[1];
Location.distanceBetween(points.latitude, points.longitude, polyCoords.latitude, polyCoords.longitude, results);
if (results[0] < 100 ) {
onpoly = true;
Marker mark = map.addMarker(new MarkerOptions().position(points).title("AddEvent")
.snippet("" + addressaddexpense).icon(BitmapDescriptorFactory.fromResource(R.drawable.addicon)));
UtilsClass.dropPinEffect(mark);
}// end if..
} // end for loop
}// end for loop
if (onpoly == true) {
Toast.makeText(getActivity(), "Poly line detected", Toast.LENGTH_SHORT).show(); …Run Code Online (Sandbox Code Playgroud) 我试图在android地图中关闭默认的infowindow.我曾经使用.hideInfoWindow()但没有任何意外.谢谢.
android ×8
google-maps ×3
android-maps ×1
eclipse ×1
geocode ×1
geolocation ×1
ggmap ×1
java ×1
maps ×1
osmdroid ×1
r ×1