Reputation: 1253
How can I add a tag for each of the marker,and the tag is always along with the marker?Because there are many markers(vehicles) on the map ,adding a tag for the marker so that user don't need to click the marker and know the license number of the marker(vehicle).
Upvotes: 0
Views: 1695
Reputation: 138
Try this: Add class in your code
private class CustomInfoWindowAdapter implements InfoWindowAdapter, IServerResponse, ServerParameterList {
private View view;
private String _spotId = "";
LinearLayout _mainlayout;
public CustomInfoWindowAdapter() {
view = getLayoutInflater().inflate(R.layout.custom_balloon_overlay,
null);
}
@Override
public View getInfoContents(Marker marker) {
if (CustomMap.this._marker != null
&& CustomMap.this._marker.isInfoWindowShown()) {
CustomMap.this._marker.hideInfoWindow();
CustomMap.this._marker.showInfoWindow();
}
return null;
}
@Override
public View getInfoWindow(final Marker marker) {
CustomMap.this._marker = marker;
String url = null;
// setup our fields
_title = (TextView) view.findViewById(R.id.balloon_item_title);
_snippet = (TextView) view.findViewById(R.id.balloon_item_snippet);
_mainlayout=(LinearLayout)view.findViewById(R.id.balloon_main_layout);
// IMPLEMENTING BALLOON DETAILS
ImageButton details = (ImageButton) view
.findViewById(R.id.balloon_details);
/*_storeIdTextView = (TextView) parent
.findViewById(R.id.balloon_storeId_custom);
_storeIdTextView.setVisibility(View.GONE);*/
if(marker.getTitle()!=null)
{
_title.setText(marker.getTitle());
}
/* if(marker.getSnippet()!=null)
{
_snippet.setText(marker.getSnippet());
}*/
return view;
}
@Override
public void serverResponse(String response, int processid) {
// TODO Auto-generated method stub
System.out.println("Response Custom"+response);
}
}
where custom_balloon_overlay is your layout
And on map use it like:
mapView.setInfoWindowAdapter(new CustomInfoWindowAdapter());
Upvotes: 0
Reputation: 11477
Use the Marker Class
and refer this link https://developers.google.com/maps/documentation/android/marker
An icon placed at a particular point on the map's surface. A marker icon is drawn oriented against the device's screen rather than the map's surface; i.e., it will not necessarily change orientation due to map rotations, tilting, or zooming.
A marker has the following properties:
Anchor
The point on the image that will be placed at the LatLng position of the marker. This defaults to 50% from the left of the image and at the bottom of the image.
Position
The LatLng value for the marker's position on the map. You can change this value at any time if you want to move the marker.
Title
A text string that's displayed in an info window when the user taps the marker. You can change this value at any time.
Snippet
Additional text that's displayed below the title. You can change this value at any time.
Icon
A bitmap that's displayed for the marker. If the icon is left unset, a default icon is displayed. You can specify an alternative coloring of the default icon using defaultMarker(float). You can't change the icon once you've created the marker.
Drag Status
If you want to allow the user to drag the marker, set this property to true. You can change this value at any time. The default is true.
Visibility
By default, the marker is visible. To make the marker invisible, set this property to false. You can change this value at any time.
GoogleMap map = ... // get a map.
// Add a marker at San Francisco.
Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(37.7750, 122.4183))
.title("San Francisco")
.snippet("Population: 776733"));
Upvotes: 0