我启用了Google Maps Android API v2的my-location图层,该图层添加了浮动按钮以转到用户的当前位置.我需要一种方法来检测此按钮上的点击.这可能吗?
今天我将Android SDK组件更新到最新版本,不知怎的,整个com.google.android.gms包已经消失了.相反,只有com.google.android.maps与gms包中的类不同.这是Google的重大变化还是我做错了什么?我一直在使用GoogleMap和LatLng类来处理谷歌地图,现在我的项目中只有错误.
我想在Google Map上显示大量标记(50k +).事实证明,Android Maps Util Library https://github.com/googlemaps/android-maps-utils似乎是群集标记时的首选.
我想知道是否存在任何最佳实践,以便在显示如此大量的标记时提高地图用户体验的性能.
例
例如,我使用群集管理器向群集管理器添加大约20.000个标记,从而在缩放和平移地图时导致不太平滑的地图交互体验.
我用过的:
GridBasedAlgorithm<MyClusterItem> gridAlgorithm = new GridBasedAlgorithm<MyClusterItem>();
mClusterManager.setAlgorithm(new PreCachingAlgorithmDecorator<MyClusterItem>(gridAlgorithm));
Run Code Online (Sandbox Code Playgroud)
我的策略:
1)在相机更改事件中从群集器中删除所有标记,然后仅添加视图边界内的那些标记.在高缩放级别上工作得很好,当缩放级别降低时,有许多标记要移除和添加,从而增加了整个聚类过程的开销
2)首先添加所有标记.
我正在向基于Android Google Maps API v2的地图片段添加带有自定义布局的InfoWindowAdapter.我在getInfoWindow()返回的视图中放了一个按钮,当它显示完全正常时,当我点击所述按钮时,窗口本身会记录一次点击(如往常一样淡黄色),而按钮则没有.
如何在信息窗口中创建一个"可点击"按钮?并且,通过扩展,信息窗口内的任何视图?
我正在尝试将新的Google Maps Android API v2合并到使用Android支持库的应用程序中.我已经经历了很多迭代,试图到某个地方工作,现在我已经放弃了,我想我应该在这里问.
我转到API控制台,创建了一个项目,为Android启用了Google Maps API v2,根据需要创建了一个调试KEY并将其粘贴到清单上.没有身份验证问题或类似的事情.很确定我做对了.
在我的项目libs文件夹中,我放置android-support-v4.jar(通过项目右键单击 - > Android->添加支持库...).在Eclipse中,我将File-> Import-> Android-> Existing Android Code To Intospace导入并导入最新的(rev 3)android-sdk/google/google_play_services/libproject/google-play-services_lib.然后我将它作为依赖库添加到我的项目中(项目右键单击 - >属性 - > Android->将其添加为底部的库依赖项.
在我的清单中我有:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ...>
<permission
android:name="myapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<All the uses-permission required like INTERNET, ACCESS_NETWORK_STATE, WRITE_EXTERNAL_STORAGE, FINE AND COARSE LOCATION, etc>
<uses-permission android:name="myapp.permission.MAPS_RECEIVE"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<application ...>
...
<uses-library android:name="com.google.android.maps" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AI..."/>
</application>
Run Code Online (Sandbox Code Playgroud)
在我的mainview.xml中,我有:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
Run Code Online (Sandbox Code Playgroud)
现在在MainView.java上我有:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; …Run Code Online (Sandbox Code Playgroud) android google-maps android-support-library google-play-services google-maps-android-api-2
I am using the Google Maps Android API Utility Library to enable clustering in my app. When five or more markers are co-located a cluster is created: 
Four or fewer similarly co-located markers won't create a cluster:

Is this by design or am I doing something wrong, because my maps have 2, 3 or 4 markers that clearly overlap, but won't form a cluster?
The code to demonstrate the problem:
Map layout:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) 我遇到了一个奇怪的崩溃,我在谷歌上找不到任何相关内容.搜索ZoomTableManager根本不返回任何结果.
E/AndroidRuntime? FATAL EXCEPTION: ZoomTableManager
Process: com.xxx.yyy, PID: 22129
java.lang.IllegalMonitorStateException: object not locked by thread before notify()
at java.lang.Object.notifyAll(Native Method)
at com.google.maps.api.android.lib6.gmm6.m.k.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.m.l.run(Unknown Source)
Run Code Online (Sandbox Code Playgroud) 我想在地图上显示我的位置并放大它.我想使用GoolgeAPIClient.地图渲染和指针创建但位置错误.我觉得即使在调用GoogleAPIClient的onConnected方法之前,也会先执行onMapReady.请帮助这是我的代码.
import android.location.Location;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
protected static final String TAG = "MainActivity";
/**
* Provides the entry point to Google Play services.
*/
protected GoogleApiClient mGoogleApiClient;
/**
* Represents a geographical location.
*/
protected Location mLastLocation;
protected String mLatitudeLabel;
protected …Run Code Online (Sandbox Code Playgroud) 基本上在向地图添加标记时,它会返回新标记,您可以像这样从中获取标记ID
Marker m = map.addMarker(new MarkerOptions()
.position(new LatLng(lat,lon)));
String id = m.getId();
Run Code Online (Sandbox Code Playgroud)
如果有很多标记并且你只想删除一个标记,有没有办法通过它的id获取标记?
试图在我正在构建的一个活动中组合一个MapFragment,但是在将它全部用于工作方面遇到了一些麻烦.我知道Maps api和Play服务都安装正确,因为我做了测试教程,一切正常.
按照这里的文档,我遇到了以下问题:在我的setUpMapIfNeeded方法中,我可以使用getFragmentManager()或getSupportFragmentManager().当我使用getFragmentManager()它时,Eclipse很酷,但是当我运行时,我得到一个NoSuchMethodError说法,该方法是未定义的.当我选择时getSupportFragmentManager(),Eclipse不喜欢它并且给我错误"无法从Fragment转换为MapFragment".那是什么交易?有什么建议?
private void setUpMapIfNeeded() {
//Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
mMap = ((MapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (mMap != null) {
//do things to the map
mMap.addMarker(new MarkerOptions().position(LOCATION).title(EXTRA_URL));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LOCATION,15));
mMap.getUiSettings().setZoomControlsEnabled(false);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我能提供任何其他代码,请告诉我,我很乐意快速发布.