IllegalStateException在Google地图上创建标记时 [英] IllegalStateException when creating markers on google map
问题描述
您好,我正在尝试在Google地图v2上显示一些标记点。一切都很好,直到我发现这个错误。出于某种原因,如果我加载了带有2个指针的贴图,然后关闭它并重新加载它,我收到以下消息:
IllegalStateException no included points
>当我调用:
LatLngBounds bounds = builder.build时出现此错误();
这就是我在地图上放置点的方法:
//将映射的侦听器指向集群
//管理器实现的侦听器。
googleMap.setOnMarkerClickListener(mClusterManager);
builder = new LatLngBounds.Builder(); (ad ad:Constants._results)
{
builder.include(new LatLng(ad.getLat(),ad.getLon()));
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener(){
@Override
public void onCameraChange(CameraPosition cameraPosition)
{
int padding = 50; //以像素为单位偏移地图边缘
try {
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,padding);
googleMap.moveCamera(cu);
googleMap.setOnCameraChangeListener(mClusterManager);
} catch(Exception e)
{
e.printStackTrace();
}
}
});
任何人都可以帮忙吗?
LogCat :
-30 14:11:11.267 20651-20874 / com.myapp.user E / com.newrelic.agent.android :错误在fireOnHarvestFinalize
java.util.ConcurrentModificationException $ b $在java.util.HashMap $ HashIterator.nextEntry(HashMap.java:806)$ b $在java.util.HashMap $ EntryIterator.next(HashMap .java:843)
at java.util.HashMap $ EntryIterator.next(HashMap.java:841)
at com.newrelic.agent.android.metric.MetricStore.getAllByScope(MetricStore.java:63 )
at com.newrelic.agent.android.metric.MetricStore.getAllUnscoped(MetricStore.java:74)
at com.newrelic.agent.android.harvest.HarvestDataValidator.ensureActivityNameMetricsExist(HarvestDataValidator.java:41 )
at com.newrelic.agent.android.harvest.HarvestDataValidator.onHarvestFinalize(HarvestDataValidator.java:15)
at com.newrelic.agent.android.harvest.Harvester.fireOnHarve stFinalize(Harvester.java:580)
at com.newrelic.agent.android.harvest.Harvester.execute(Harvester.java:271)
at com.newrelic.agent.android.harvest.HarvestTimer。 (com.newrelic.agent.android.harvest.HarvestTimer.tickIfReady(HarvestTimer.java:56)
在com.newrelic.agent.android.harvest.HarvestTimer处打勾(HarvestTimer.java:73)
。 (java.util.concurrent.Executors)
$ Runtime.Adapter.call 279)
在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 301(ScheduledThreadPoolExecutor.java:152)
在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)$ b $在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPo
at java.lang.Thread.run(Thread.java:841)
我认为您的问题在于此。
._results)
{
builder.include(new LatLng(ad.getLat(),ad.getLon()));
}
Constants._results必须为空,所以在构建器中没有LatLng点。调试并检查。
Hi I am trying to display some marker points on a Google map v2. All is good until I found this bug. For some reason if I load the map with 2 pointers on it and then close it and reload it again I get this message:
"IllegalStateException no included points"
This error appears when I call the:
LatLngBounds bounds = builder.build();
This is how I put the points on the map:
// Point the map's listeners at the listeners implemented by the cluster
// manager.
googleMap.setOnMarkerClickListener(mClusterManager);
builder = new LatLngBounds.Builder();
for (Ad ad : Constants._results)
{
builder.include(new LatLng(ad.getLat(), ad.getLon()));
}
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition)
{
int padding = 50; // offset from edges of the map in pixels
try{
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.moveCamera(cu);
googleMap.setOnCameraChangeListener(mClusterManager);
}catch (Exception e)
{
e.printStackTrace();
}
}
});
Can anyone help out?
LogCat:
-30 14:11:11.267 20651-20874/com.myapp.user E/com.newrelic.agent.android﹕ Error in fireOnHarvestFinalize
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)
at java.util.HashMap$EntryIterator.next(HashMap.java:843)
at java.util.HashMap$EntryIterator.next(HashMap.java:841)
at com.newrelic.agent.android.metric.MetricStore.getAllByScope(MetricStore.java:63)
at com.newrelic.agent.android.metric.MetricStore.getAllUnscoped(MetricStore.java:74)
at com.newrelic.agent.android.harvest.HarvestDataValidator.ensureActivityNameMetricsExist(HarvestDataValidator.java:41)
at com.newrelic.agent.android.harvest.HarvestDataValidator.onHarvestFinalize(HarvestDataValidator.java:15)
at com.newrelic.agent.android.harvest.Harvester.fireOnHarvestFinalize(Harvester.java:580)
at com.newrelic.agent.android.harvest.Harvester.execute(Harvester.java:271)
at com.newrelic.agent.android.harvest.HarvestTimer.tick(HarvestTimer.java:73)
at com.newrelic.agent.android.harvest.HarvestTimer.tickIfReady(HarvestTimer.java:56)
at com.newrelic.agent.android.harvest.HarvestTimer.run(HarvestTimer.java:32)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:279)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
I think your problem lies here
for (Ad ad : Constants._results)
{
builder.include(new LatLng(ad.getLat(), ad.getLon()));
}
Constants._results must be empty, so there are no LatLng points in your builder. Debug and check.
这篇关于IllegalStateException在Google地图上创建标记时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!