Cannot resolve symbol ItemizedOverlay - android

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.

Related

Custom POI data into the Google Map

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"));
}

Custom Markers in Google Maps

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..!

Google Maps remove marker route context menu

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
}

Navigation Marker

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"));

Show InfoWindow of point on map long press

Using the Google Maps app as an example for what I mean, when you long press on the map it loads the closest address in an InfoWindow.
How can I display an InfoWindow on the position of the map that I just long pressed on without putting down a marker?
My guess is that Google Maps app adds a marker with 1x1px transparent bitmap (or maybe even 0x0px).
To detect onMapLongClick:
Implement OnMapLongClickListener
Call myMap.setOnMapLongClickListener(this) to register.
Override onMapLongClick(LatLng point) to add marker by calling
myMap.addMarker(new MarkerOptions().position(point).title("title")).
#Override
public void onMapLongClick(LatLng point) {
tvLocInfo.setText("New marker added#" + point.toString());
myMap.addMarker(new MarkerOptions().position(point).title(point.toString()));
}
Here is an example for that. Check here
When you've created the marker it's easy to add an infowindow to that marker and open it.

Categories

Resources