Google maps marker show only icon - java

I want to display markers on google maps (android)
I used this code (like in the example in android developer):
The location, name and descripion are valid (I checked them via debug mode)
It shows me the icon on the desired location, however without the marker or the description and snippets. The following line
mMap.addMarker(MarkerOptions().position(location)
.title(poi.getName()).snippet(poi.getDescription())
.icon(BitmapDescriptorFactory.fromBitmap(image_item));
shows me only the icon without the title or snippest.
Thanks a lot

Did you follow the examples from the documentation? Also, the sample code bundled with the Google Play services SDK?
Edit: You can show an info window programmatically by calling showInfoWindow() on the target marker:
Marker marker = mMap.addMarker(new MarkerOptions()
.position(location)
.title(poi.getName())
.snippet(poi.getDescription())
.icon(BitmapDescriptorFactory.fromBitmap(image_item));
marker.showInfoWindow();
However, bear in mind that only one info window can be displayed at a time. If a user clicks on another marker, the current window will be hidden and the new info window will be displayed.

try this code.
This code is work on Google map with API V2
Add the inbuilt method of google.
public void onMapLongClick(LatLng point) {
// Getting the Latitude and Longitude of the touched location
latLng = point;
// Clears the previously touched position
myMap.clear();
// Animating to the touched position
myMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
// Creating a marker
markerOptions = new MarkerOptions();
// Setting the position for the marker
markerOptions.position(latLng);
// Adding Marker on the touched location with address
new ReverseGeocodingTask(getBaseContext()).execute(latLng);
tmpLatLng = latLng;
drawCircle(point);
btLocInfo.setEnabled(true);
}

This is not a rare problem the only way to fix it is to reinstall its the only way was able to fix it .

show icon without the title or snippest. use below code
LatLng newYork = new LatLng(40.7142, 74.0064);
Marker melbourne = map.addMarker(new MarkerOptions()
.position(newYork));
Edited:
show marker with title & Snippest & icon
map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
.title(string).snippet(string2).icon(BitmapDescriptorFactory.fromBitmap(image_item));

Related

Add marker using Lat/Lng when Google Map loads

I want to know
if we can add marker in Google Maps using longitude and latitude provided from firebase database. When maps fragment is loaded.
In simple I want to add markers in Google Maps using my own longitude and latitude and it should mark all the places say if I have 10 place's lng and lat.
Now I want to show all 10 places on Google Maps and some additional information also
Yes you can. Ther is a function addMarker() on map object to do that:
#Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions()
.position(new LatLng(10, 10))
.title("Hello world"));
}
Documentation:
https://developers.google.com/maps/documentation/android-api/marker

Google Maps Pin in my Android application

I need to display user inserted pins on the map that i will have in my application.
This pin needs to be visible to all the users using the app.
I have no clue how to implement this.
Can i get some help please?
Pins in Google Maps are called Markers and they are pretty simple to create.
Following what is documented from the Google Maps API here, you just use the addMarker() method to create a marker and can customize the options of where it should be placed and the title to show when it is clicked on
#Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions()
.position(new LatLng(10, 10))
.title("Hello world"));
}

How do I get the blue location dot to appear in my Android application?

I'm fairly new to Android programming and I'm a bit stuck. I have a map set up and now I want to add the blue flashing dot to the application to show where the user is on the map.
How do I do this?
Just try implementing this code, hope this works fine for you.
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Hello world")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
If it does not work for you, try keep in touch with me.

Google maps mark (current location) crashes the application, how to fix it?

I am trying to add current location mark to my android Google map application in Android Studio.
My code:
private void setUpMap() {
Location location = null;
LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());
Marker marker;
marker = mMap.addMarker(new MarkerOptions().position(new LatLng((location.getLatitude()), location.getLongitude())).title("Marker"));}
It causes my application to crash. Underneath there are mistakes that appeared while running my application:
http://postimg.org/image/qrxdo9dl5/full/
(I used postimage to upload a larger size screen-shot)
Before I modified my code, I had a working code set to position 0,0:
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
Then I tried to change location '0,0' to read current latitude and longitude and show it on my Google map. I changed my code based on this post: How to get the current location in Google Maps Android API v2?
I am a java beginner and any help is much appreciated. Thank you very much for any help.
You are getting a NullPointerException because your Location object is set to null. In the linked answer the location object comes from the location callback.
public void onMyLocationChange(Location location) // location object here
You can easily get the Location from your map reference like so
Location location = mMap.getMyLocation();
However this method is deprecated and using the location API is encouraged. To get location from the API you can follow this guide:
https://developer.android.com/training/location/retrieve-current.html
You build a GoogleApiClient, connect it, and then use it to get a location.
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

Google Maps update map based on if drive is active

I'm making an uber clone app
this is my code and it checks if there is any drive active if so it updates the rider location
if (driverActive != false) {
LatLng userLocation = new LatLng(location.getLatitude(), location.getLongitude());
mMap.clear();
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(userLocation, 20));
mMap.addMarker(new MarkerOptions().position(userLocation).title("Your Location"));
}
android studio shows a warning driverActive != false' can be simplified to 'driverActive'and it doesnt update the rider map
but if I remove driverActive if statement it works and updates the location of the rider...
any help would be appreciated
It turned it outs just the ParseUser functions that didn't log the anonymous user and thus making it crash because when the check function gets the info it gets nothing making driverActive null while crashing my app..
Thanks anyway

Categories