android Google map API v2 doesn't display street names - android

I'm displaying a map using google maps API v2 but it doesn't show any street names. It shows the satellite image but no text. What am I doing wrong here?
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gmaps);
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
map.setInfoWindowAdapter(new MyInfoWindowAdapter(this, getLayoutInflater()));
map.setOnMapLongClickListener(this);
map.setOnInfoWindowClickListener(this);
map.setOnMarkerClickListener(this);
mMyLocation = map.getMyLocation();
setMarkerOnLocation();
}

This works as designed. You are setting the map in Satellite mode and according to https://developers.google.com/maps/documentation/android/map#map_types
Satellite
Satellite photograph data. Road and feature labels are not visible.
Hybrid
Satellite photograph data with road maps added. Road and feature labels are also visible.
So you'll need to use the following if you want the labels to show:
GoogleMap map;
...
// Sets the map type to be "hybrid"
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);

You have just given current location and didnt given any latitude and longitude points
For example:
LatLng one = new LatLng(13.549881,77.711792);//
Marker myMarkerOne = gm.addMarker(new MarkerOptions()
.position(one)
.title("Name of location")
.snippet("Name of street")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
and if you want to get dynamically means use json map parsing which is given here.

Related

How to open the title of a marker in google maps v.3 when camera arrives above it?

I have a few markers added on a map. I'm using a model class to hold data, so I'm adding the markers using the following code:
LatLng latLng = new LatLng(model.getLat(), model.getLng());
MarkerOptions marker = new MarkerOptions().position(latLng).title(model.getName());
googleMap.addMarker(marker);
I'm also using a method to move the camera to a specific position on user click. My method looks like this:
private void moveCamera(Model model) {
moveCamera(new LatLng(model.getLat(), model.getLng()), DEFAULT_ZOOM);
}
So when the user clicks on the name of a location which is in a list, I'm moving the camera over that location. How can I automatically open the title of that marker, when the camera arrives above that location?
Thanks in advance!
You have this code to create your MarkerOptions:
LatLng latLng = new LatLng(model.getLat(), model.getLng());
MarkerOptions markerOption = new MarkerOptions().position(latLng).title(model.getName());
When you add the Marker to your map just keep a reference to the object:
Marker marker = googleMap.addMarker(markerOption);
Now you can show the info window:
marker.showInfoWindow();

Clear / Re-position marker (onClick)

How can I clear the recent markers or declare a new marker without using the .addMarker or new Tag? (or any way to do this, if you have an idea)
I use the codes below to add a marker(the one in comment) and it works but since it's in ".addMarker(new Marker...) tag, it creates a new marker every time I click my button. I tried to make a declared marker, and set the marker position, but I think it just doesn't work that way.
Concept: I'm getting my current location onClick, but it creates a new marker instead of re-positioning the last marker I have. T.I.A.
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
x = Double.valueOf(locX);
y = Double.valueOf(locY);
LatLng loc = new LatLng(x, y);
//mMap.addMarker(new MarkerOptions().position(loc).draggable(true).title("Building Location"));
marker.setPosition(loc);
marker.isDraggable();
marker.setTitle("Building Location");
mMap.moveCamera(CameraUpdateFactory.newLatLng(loc));
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
you can clear old marker before setting a new one like this -
mMap.clear(); //add this , it will clear old markers. if any
//then set new marker.
mMap.addMarker(new MarkerOptions().position(YOUR_NEW_LOCATION).draggable(true).title("Building Location"));

Add pin(not marker) to google map Android

How to add a pin(not a marker)to the google map in android?
I know how to add a marker, something like this:
map.addMarker(new MarkerOptions()
.position(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()))
.title(getString(R.string.start_location_marker)));
But I want a pin, not a marker.
A pin looks like this:
pin
A marker looks like this:
marker
set your pin image to marker it is called custom marker
#Override
public void onMapReady(GoogleMap googleMap) {
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.pin);
LatLng latLng = new LatLng(21.4225, 39.8262);
googleMap.addMarker(new MarkerOptions().position(latLng).title("Mecca").icon(icon)).showInfoWindow();
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
}

Maps in TabActivity overlaps each other

I have implemented the TabActivity in which there are 3 tabs. And each tab contains a map view.
When I switch the tabs,
The map of one tab is shown on the top of map of other tap.
This is my code for maps inside tabs:
GoogleMap map;
public void mapshow(String Message,int mapId) {
// google map start
SupportMapFragment fragment;
fragment =(SupportMapFragment)getSupportFragmentManager().findFragmentById(mapId);
// Getting reference to Google Map
map = fragment.getMap();
// Clear all the markers from the Google Map
map.clear();
MarkerOptions markerOptions = new MarkerOptions();
LatLng point = new LatLng(latitude, longitude);
// Setting position for the marker
markerOptions.position(point);
// Setting custom icon for the marker
markerOptions.icon(BitmapDescriptorFactory
.fromResource(R.drawable.marker));
// Setting title for the info window
markerOptions.title(Message);
// markerOptions.snippet("Showing a demo map marker.");
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// Move the camera to the user's location and zoom in!
map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
latitude, longitude), 14.0f));
// Adding the marker to the map
Marker marker = map.addMarker(markerOptions);
marker.showInfoWindow();
map.setOnMarkerClickListener(this);
map.getUiSettings().setZoomControlsEnabled(false);
// end google
}
So how to hide the previously selected tab's map when I switch the tab?

Add marker on google map on touched location in Android

Can anyone help me in the following task:
I want to add a marker in google map in android.
The functionality has to be like this that a pop up window have to be shown to add the touched location as a marker.
I was referring the below tutorial in that they add the marker through hard coding.
http://developer.android.com/resources/tutorials/views/hello-mapview.html
I want it that to be done using onclck on the map.
I used Google Maps API v2 and the solution is given below:
googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
#Override
public void onMapClick(LatLng point) {
MarkerOptions marker = new MarkerOptions()
.position(new LatLng(point.latitude, point.longitude))
.title("New Marker");
googleMap.addMarker(marker);
System.out.println(point.latitude + "---" + point.longitude);
}
});
In MapView you must use onTouch instead of onClick. The motionEvent that this event fires, has the touch coordinates so with the getProjection() method from MapView you can convert the touch coordinates into lat and long to put the Overlay (Marker) on the map.

Categories

Resources