Plotting on maps in android - android

I am making an application where I get an message with latitude and longitude, I search that and then plot it on google maps.
How to accomplish the plotting ??

If by "plotting on the map" you mean adding a marker (icon) to a map at a given Latitude / Longitude, you can use the following code to put a Marker on Sydney on the map :
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(-33.88,151.21))
.title("Hello world"));
The LatLng object accepts 2 doubles representing a latitude and a longitude in degrees.
The Google Maps Android API v2 is pretty well-documented. There's also a guide on Markers in Google Maps Android API v2

Related

How to locate a point on google map by passing latitude and longitude in android app

I am a newbie in android programming, I have a set of latitude and longitude coming from API, I want to show the location corresponding to that latitude and longitude on google map, I tried searching through google but did not found any suitable link. Please help.
googleMap.addMarker(new MarkerOptions().position(yourLat, yourLon)
.title("Marker title"));
This is straight forward. You can use Marker for this, try below code,
float myLatitude = <some value>
float myLogitude = <some value>
GoogleMap map = //initiate your map
Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(myLatitude, myLogitude))
.title("Location Name"));
map.add(marker);
For more info check this link
SampleCode

android automatic title on red marker on Google Maps

I have a android map application where it track the user location and display it on the map. i make it so that there will be a title "you are here" that appear on top of the red marker. however, it did not appear on its own and i must tap on the red marker. and i could tap on any red marker and the title would move there and disappear on the previous one.
how do i make it so that it only appears on the latest red marker(latest location) on its own and cannot be removed?to show the user his current location.
the speed i set it at 1. i do not know whether it is good enough. the location stopped updating while i was not moving but it is still slow and inaccurate.
public void onLocationChanged(Location myLocation) {
System.out.println("speed " + myLocation.getSpeed());
if(myLocation.getSpeed() > speed)
{
//show location on map.................
//Get latitude of the current location
double latitude = myLocation.getLatitude();
//Get longitude of the current location
double longitude = myLocation.getLongitude();
//Create a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);
//Show the current location in Google Map
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//Zoom in the Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));
Try This:-
Marker pos = googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));
instead of
googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));
Or
Write this, it is very easy:-
locationMarker.showInfoWindow();
You can't really achieve this by using the existing API's on Android, without coding a lot of custom views and controls.
There's a nice library which you can use to customize the markers on your maps. Here's an example taken from it's website. It's called android-maps-utils
The link to the library on github.
https://github.com/googlemaps/android-maps-utils
And the website, where you can find a video and other examples.
http://googlemaps.github.io/android-maps-utils/

Google Maps Android API v2 Show marker on zoom level

How can show markers on specific zoom level using Google Maps Android API v2? I have more than 1000 Markers, so it's not good idea to show all on start.
Here is simple example:
#
// latitude and longitude
double latitude = 40.738933;
double longitude = -74.001366;
// create marker
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps ");
// adding marker
googleMap.addMarker(marker);
#
Thank you for help
put below code
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
here Move the camera instantly to marker with a zoom of 15. if you wanna change zoom level you can change.

Google Maps v2 zoom to specific marker

I have a search AutoComplete in my map and display the title from my database. Can it be possible to put zoom functionality to that specific marker? I'm using google maps api v2.
Look at these code snippets:
https://developers.google.com/maps/documentation/android/
This should be what you're looking for:
GoogleMap map = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
LatLng sydney = new LatLng(-33.867, 151.206);
map.setMyLocationEnabled(true);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));

Google Maps API v2 Marker with Street View Image as Icon

I'm using Google Maps Android API v2 and I've got everything set up correctly. I have set some markers based on latitude / longitude.
How can I add the Street View image of the lat/lng as an icon?
/* Google Maps API v2 map set code here */
Marker marker = map.addMarker(new MarkerOptions().position(point)
.title("Title")
.snippet("Snippet")
.icon( StreetViewObject? ));
Thanks
You can use this api to get an image based on your latitude and longitude:
https://developers.google.com/maps/documentation/streetview/

Categories

Resources