【发布时间】:2017-07-06 09:31:16
【问题描述】:
我已经实现了一个简单的谷歌地图,我根据我拥有的列表显示一个标记列表。
为了显示它们,我遍历列表并创建每个标记,如下所示:
for (final PhotosForPlants p : photos) {
if (p.getLat() != null && p.getLon() != null && p.getLat() != 0.0 && p.getLon() != 0.0) // check for 0.0
{
if (p.getId() == currentPlantId) {
plantLocation = new LatLng(p.getLat(), p.getLon());
yellowPos = plantLocation;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(plantLocation, 35f));
Marker m = mMap.addMarker(new MarkerOptions().position(plantLocation)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));
m.setTag(p);
markers.add(m);
} else {
plantLocation = new LatLng(p.getLat(), p.getLon());
positions.add(plantLocation);
positionSave = index;
Marker m = mMap.addMarker(new MarkerOptions().position(plantLocation)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
m.setTag(p);
markers.add(m);
}
}
index++;
}
}
我需要从我的服务器加载方形图像,而不是简单的标记图像,我尝试使用 picasso,但我不知道这样做是否有任何问题位图:
public void loadBitmap(String url) {
if (loadtarget == null) loadtarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// do something with the Bitmap
handleLoadedBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(this).load(url).into(loadtarget);
}
public Bitmap handleLoadedBitmap(Bitmap b) {
return b;
}
我的主要问题是我不知道如何检索为特定标记加载的每个图像,以及如何使用我的地图将其设置为 ip:S。
有什么帮助吗?
【问题讨论】:
标签: java android google-maps geolocation marker