Android: MapOverlay - Current location - android

I am currently creating an Android application, that shows the user its current location on Google Maps. I currently have it working so brings up the location, zoomed in.
However, I want the location to be pin-pointed. I have attempted to try and follow the HelloMapView tutorial, but have been having difficulty. How do I modify what the tutorial is saying, to make the Overlay, show the current location?
Also, I have been getting an error, with the getDrawable part of the following:
Drawable drawable = ((Object) this.getResources()).getDrawable(R.drawable.androidmarker);
ItemizedOverlay itemizedoverlay = new ItemizedOverlay(drawable, this);
Also, whereabouts do I paste this:
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
Thank you.

Related

Does Google Maps Android API locate me automatically?

I am working with Google Maps Android API V2.
When my map fragment is loaded it shows my location automatically (with the blue dot). Why does this happen? Is my location history affecting or is the default working mode?
Does this code cause it?:
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
#Override
public void onMyLocationChange(Location location) {
googleMap.setOnMyLocationChangeListener(null);
}
});
I have commented this piece of code but the map is still showing the blue dot.
If this is not happening because of the history, would this piece of code be enough to get user location or do I need to use LocationManager class as described in other questions?
Try to use
googleMap.setMyLocationEnabled(true/false);
to control showing your location on map. I think it is enough to turn the setting on to make your location work with Google Maps, without need to use LocationManager etc.

Default current location pin in Skobbler map

I am using skobbler map for Android. I do not require current location to pointed on the map, so I am not registering for the current location listener and skobbler map itself adds an default current location pin on the map. Please check the image attached. , please tell me how to not display this. And, by default the maps takes to Berlin, Germany can this be avoided? If yes, how?
You can set the behavior of the default position annotation with mapView.getMapSettings().setCurrentPositionShown(false).
To center the map on a desired location use mapView.centerMapOnPosition(skPosition).
Where mapView is your SKMapSurfaceView instance.
Please check the below code hope its help you.As its working at my end.
#Override
public void onCurrentPositionUpdate(SKPosition skPosition) {
this.currentPosition = skPosition;
SKPositionerManager.getInstance().reportNewGPSPosition(this.currentPosition);
mapView.animateToLocation(skPosition.getCoordinate(), 7);
mapView.animateToZoomLevel(7);
}
You can try to call in onSurfaceCreated:
SKCoordinate coord = new SKCoordinate(-37.585162f, 40.418143f);
mapView.setPositionAsCurrent(coord, 0, true);
mapView.setZoom(4);

osmdroid trigger tap on mapview

I am develpoing a map application with OpenStreetMaps. I am trying to generate a tap on a point from a org.osmdroid.views.MapView like can be done in Google Maps for Android:
HelloItemizedOverlay o = new HelloItemizedOverlay(drawable,getApplicationContext());
o.onTap(GeoPoint p, MapView mapView);
So far I haven't found an equivalent solution.
I realized that what I wanted to do was triggering a call to my implementation of onItemSingleTapUp on a specified item, so i did it:
this.onItemSingleTapUp(0, itemizedoverlay.getItem(0));

Show Taiwan Map in Android Application

Here I develop one application which shows Map in Application. I show map in my app and it is working fine, but I show that country which I want to display in Map from application. So how to do it? Is it possible in Android?
Please help me.
Thanks in Advance.
First of all track you current position through LocationListener/LocationManager:
MyLocation myLocation = new MyLocation();
private void locationClick() {
myLocation.getLocation(this, locationResult);
}
And, zoom out your location through code:
mapView.getController().setZoom(17);
Then you can see the country mentioned.

Google maps: change from satellite view to street view

I want to to change the google map view from one state to another. Currently the view is satellite view, now I want to change it to street view. I have written as below but it's not changing the view. How do I change the view at run-time?
mapView.setStreetView(true);
After that put this line and let me know what happen,
mapView.invalidate();
In your code you have to do something like,
mapView.setStreetView(true);
mapView.setSatellite(false);
mapView.invalidate();
Uninstall the project from the emulator and again run it.It hope it will work.
As the MapView reference shows, setStreetView does not change the map to street view - it only toggles showing the blue streaks indicating whether street view is available or not, on the map position you're currently looking at. I would guess that the easiest way to start street view is to start google's own street view app via StartActivity.
mapView.setStreetView(true);
Is depreciated.
try {
Intent streetView = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("google.streetview:cbll="+my_lat+","+my_lng+"&cbp=1,99.56,,1,-5.27&mz=21"));
streetView.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(streetView);
} catch ( Exception ex ) {
Toast.makeText(getBaseContext(), "Could not launch Goole Street View. Are you sure it's installed? Launching market...", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.street"));
startActivity(intent);
}
Without the try/catch your app will crash if street view isn't installed.
See this possible duplicate
mapView.setStreetView(true);
mapView.setSatellite(false);
mapView.invalidate();

Categories

Resources