I have SupportMapFragment and I need to add custom controls into it for changing a map type. Calling getView(), I get NoSaveStateFramelayout and I don't think it is a good idea to add it directly into it or its children.
What is the best way how can I can add a button over my map for changing the map type?
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.
Create a new styleIn the Google Cloud Console, go to the Map Styles page. Click Create Style, and choose the Google Map radio button. Click Save. In the Save and Publish Map dialog, enter a map name and optional description, and click Save.
I have decided to override onCreateView and encapsulate the map in the code.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
View mapView = super.onCreateView(inflater, viewGroup, bundle);
RelativeLayout view = new RelativeLayout(getActivity());
view.addView(mapView, new RelativeLayout.LayoutParams(-1, -1));
// working with view
return view;
}
And it works as I needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With