1
我有一個關於點擊地圖標記時彈出的氣泡的問題。我搜查了互聯網,但沒有真正令人滿意的答案。基本上我的問題是:有沒有辦法讓我的泡泡出現在默認情況下,而不需要點擊它?Android Map v2標記泡泡
在代碼中,我在下面所示的這部分:
MarkerOptions tousgårdsladen = new MarkerOptions()
.position(TOUSGÅRDSLADEN).title("Activity Name")
.snippet("Snippet");"
如果你點擊一個泡沫與文本彈出的標記「活動名稱」所以基本上我想,泡沫出現的標誌物沒有我點擊加載,如果你點擊它會給你更多關於放置標記的活動的細節。
public class MapFragment extends Fragment {
Activity activity;
double lat;
double lng;
LatLng currentPosition;
SeekBar seekBar;
TextView textView;
GoogleMap map;
static final LatLng TOUSGÅRDSLADEN = new LatLng(56.16266, 10.13851);
static final LatLng DORTESVE = new LatLng(56.15952, 10.13570);
static final LatLng GELLERUP = new LatLng(56.154633, 10.133679);
private HashMap<Marker, Event> eventMarkerMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.e(tag, "inside create map_view");
// Context
activity = getActivity();
View rootView = inflater.inflate(R.layout.map_layout, container, false);
SetMap();
SetCameraLocation();
textView = (TextView) rootView.findViewById(R.id.slide_bar_text);
seekBar = (SeekBar) rootView.findViewById(R.id.slide_bar);
SetSeekBar();
return rootView;
}
private void SetCameraLocation() {
LocationManager locationManager = (LocationManager) activity
.getSystemService(activity.LOCATION_SERVICE);
Location location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
currentPosition = new LatLng(location.getLatitude(),
location.getLongitude());
map.moveCamera(CameraUpdateFactory.newLatLngZoom(currentPosition,
14));
} else {
// default is setted to Gellerup
currentPosition = new LatLng(56.154633, 10.133679);
}
map.moveCamera(CameraUpdateFactory.newLatLngZoom(currentPosition, 14));
}
private void SetMap() {
map = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
if (map != null) {
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.setMyLocationEnabled(true);
// map.getUiSettings().setZoomControlsEnabled(false);
MarkerOptions tousgårdsladen = new MarkerOptions()
.position(TOUSGÅRDSLADEN).title("Activity Name")
.snippet("Snippet");
;
MarkerOptions dortesve = new MarkerOptions().position(DORTESVE)
.title("Activity Name").snippet("Snippet");
map.addMarker(tousgårdsladen);
map.addMarker(dortesve);
}
}
private void SetSeekBar() {
seekBar.setMax(2); // Three options
seekBar.incrementProgressBy(1);
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
int kilometers = 0;
switch (progress) {
case 0:
kilometers = 2;
break;
case 1:
kilometers = 4;
break;
case 2:
kilometers = 6;
break;
}
textView.setText(kilometers + " km");
LoadTrack loadTrack = new LoadTrack();
List<Location> list = loadTrack.decodeGPX(activity);
PolylineOptions line = new PolylineOptions();
line.width(5);
line.color(R.color.palegreen);
for (Location location : list) {
LatLng latLng = new LatLng(location.getLatitude(), location
.getLongitude());
line.add(latLng);
}
map.addPolyline(line);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/slide_bar_text"
/>
<SeekBar android:id="@+id/slide_bar"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/palegreen"
/>
<TextView android:id="@+id/slide_bar_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@id/slide_bar"
android:text="4"/>