I started a new project with the Google Maps template of Android Studio and just added a marker to the map.
LatLng location = new LatLng(lat, lng);
Marker marker = mMap.addMarker(new MarkerOptions()
.position(location)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
When I click the Marker there comes a little menu with a Google Maps icon on the bottom right corner:
How can I get rid of this thing? I couldn't find anything I even don't know how to call it but I really need to get rid of it.
You need to call setMapToolbarEnabled method of UiSettings
Like this:
#Override
public void onMapReady(GoogleMap googleMap) {
googleMap.getUiSettings().setMapToolbarEnabled(false);
// Do other staff
}
Related
I have created a app and have implemented Google maps.
Am I allowed to incorporate my own custom POI data into the Google Map developing a Android app?
Yes, you can add markers to the map like in the code below. You can find a full tutorial here.
#Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions()
.position(new LatLng(10, 10))
.title("Hello world"));
}
i got this error when i extends ItemizedOverlay on Activity. How can i resolve this error ? can any one help me out here.
ItemizedOverlay is no longer available in Google Maps v2.
If you would like to display marker on a map you can user Marker class. You can create Marker object using MarkerOptions.
I'm attaching the simplest example:
#Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions()
.position(new LatLng(52.2330653, 20.9211106))
.title("Warsaw"));
}
In addition I recommend reading Google Maps Android API and Markers section.
You can make a marker draggable using:
MarkerOptions.draggable(boolean)
Marker.setDraggable(boolean)
You can also attach marker drag listener, you can find more here.
I have built a music app and now I am trying to build a mapping feature more like Shazam's or Instagrams as follows:
Where initially, I am to drop a general marker on several points without actually showing all the activity in that location. Then on tapping that marker, the map will zoom in and other markers that are more specific will show, and so on..
Is there a tutorial available that I can follow the to achieve this effect in Android?
I have just found out that Google has a utility library that provides for marker clustering. The documentation can be found here https://developers.google.com/maps/documentation/android-api/utility/marker-clustering
You can create a method to add custom markers using this function:
private void drawCustomMarker(LatLng point) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(point);
markerOptions.title("SMS");
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.sms));
mMap.addMarker(markerOptions);
}
You can pass LatLng object where you want to drop the marker. I have used it in map click listener:
mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
#Override
public void onMapLongClick(LatLng newlatLng) {
drawCustomMarker(newlatLng);
}
});
Hope it will help you..!
In my Android application my map screen shows direction and Google map when click marker on the map. I use the following in my application.
XML:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
In code:
GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
I have marked the direction and Google map icon marked in blue color. please see the image of my map screen.
How to hide direction and Google map icon from map fragment?
Google Map provides a simple boolean method for this:
gmap.getUiSettings().setMapToolbarEnabled(false);
And You are done.
TL;DR version:
Try overriding OnMarkerClickListener and return true.
Longer version:
When you return true you say to GoogleMap
I, the developer, handled a click on the Marker. You, the GoogleMap, don't have to do anything.
So as a result GoogleMap does not perform its default action which in this case would be: show those buttons (which you don't want).
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// for Map tool disable
mMap.getUiSettings().setMapToolbarEnabled(false);
// for Zoom Button Enable on Google Map
mMap.getUiSettings().setZoomControlsEnabled(true);
//for Location Button enable on Google Map
mMap.getUiSettings().setMyLocationButtonEnabled(true);
}
It's Called Map toolbar
You can enable and disable the toolbar by calling UiSettings.setMapToolbarEnabled(boolean).
I'm making a Navigation based application for Android using API. I have successfully added Google Maps to my app. But now I want to add navigation marker (arrow like symbol) same as we see in official Navigation app of Google. I searched allot but didnt found anything. So can anyone help me out?
There is a link to a good read about this.
Try this:
GoogleMap map;
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Hello world"));