我正在开发一个Android应用程序,具有含一个MapView ... 包含根据本地数据库中的位置的标记的MapView片段.. 有什么办法动画,甚至改变只点击标记的颜色? 我的意思是我已经做到了在setOnMarkerClickListener,但是,当我在另一个标记点击,上一个标记还是相同的颜色/动画...添加动画拖欠setOnMarkerClickListener Maps API第2机器人标记
添加下面的代码的主要部分...
String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
Cursor c = myDataBase.rawQuery("Select * from location", null);
if (c != null) {
if (c.moveToFirst()) {
do {
id = c.getInt(0);
if (userPrefs.getString("locale",null)==null || userPrefs.getString("locale",null).equals("en"))
{
storename = c.getString(1);
}
else {
storename = c.getString(7);
}
stlatitude = c.getDouble(2);
stlongitude = c.getDouble(3);
city = c.getString(4);
String emirate = c.getString(5);
storeloc = new Location("StoreLocation");
storeloc.setLatitude(stlatitude);
storeloc.setLongitude(stlongitude);
addmarker();
}
while (c.moveToNext());
}
}
myDataBase.close();
map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
String s= marker.getTitle();
String snippet= marker.getSnippet();
markerlat= marker.getPosition().latitude;
markerlong= marker.getPosition().longitude;
marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
tv.setText(s);
tv1.setText(snippet);
if (s.equals(getActivity().getResources().getString(R.string.here))) {
if (relbutton.getVisibility() == View.VISIBLE && reltext.getVisibility() == View.VISIBLE) {
relbutton.setAlpha(1.0f);
relbutton.animate().translationY(0).alpha(0.0f);
relbutton.setVisibility(View.GONE);
} else if (relbutton.getVisibility() != View.VISIBLE && reltext.getVisibility() != View.VISIBLE) {
reltext.setVisibility(View.VISIBLE);
reltext.setAlpha(0.0f);
reltext.animate().translationY(0).alpha(1.0f);
if (userPrefs.getString("locale",null).equals("ar"))
{
RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.relativeLayout2);
relativeLayout.setGravity(Gravity.LEFT);
RelativeLayout relativeLayout1 = (RelativeLayout) view.findViewById(R.id.relativeLayout1);
relativeLayout1.setGravity(Gravity.RIGHT);
}
}
} else if (relbutton.getVisibility() != View.VISIBLE && reltext.getVisibility() != View.VISIBLE) {
relbutton.setVisibility(View.VISIBLE);
reltext.setVisibility(View.VISIBLE);
reltext.setAlpha(0.0f);
reltext.animate().translationY(0).alpha(1.0f);
relbutton.setAlpha(0.0f);
relbutton.animate().translationY(0).alpha(1.0f);
if (userPrefs.getString("locale",null).equals("ar"))
{
RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.relativeLayout2);
relativeLayout.setGravity(Gravity.LEFT);
RelativeLayout relativeLayout1 = (RelativeLayout) view.findViewById(R.id.relativeLayout1);
relativeLayout1.setGravity(Gravity.RIGHT);
}
} else if (reltext.getVisibility() == View.VISIBLE) {
relbutton.setVisibility(View.VISIBLE);
relbutton.setAlpha(0.0f);
relbutton.animate().translationY(0).alpha(1.0f);
if (userPrefs.getString("locale",null).equals("ar"))
{
RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.relativeLayout2);
relativeLayout.setGravity(Gravity.LEFT);
RelativeLayout relativeLayout1 = (RelativeLayout) view.findViewById(R.id.relativeLayout1);
relativeLayout1.setGravity(Gravity.RIGHT);
}
}
return true;
}
});
directions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nwLocation = appLocationService.getLocation(LocationManager.NETWORK_PROVIDER);
if(nwLocation!=null) {
userlatitude = nwLocation.getLatitude();
userlongitude = nwLocation.getLongitude();
if(markerlat!=null && markerlong!=null) {
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr=" + userlatitude + "," + userlongitude + "&daddr=" + markerlat + "," + markerlong;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
}
}
else {
showSettingsAlert("NETWORK");
}
}
});
return view;
}
private void addmarker() {
markerOptions.position(new LatLng(stlatitude, stlongitude));
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET));
markerOptions.title(getActivity().getResources().getString(R.string.xpressionsstyle));
markerOptions.snippet(storename);
map.addMarker(markerOptions);
}
有多少标记要绘制地图画面上? –
尽可能多的数据库中的位置... –
所有的制造商应该在不同的颜色? –