How to set mapview to not show my current location? - android

how to coding to set mapview don't show the current location
now it's not show on emulater but when I try to install on my mobile , the current location sigh will show
What should I do?

public static int getCoordinateE6(double coordinate) {
return (int) (coordinate * 1E6);
}
GeoPoint geoPoint = new GeoPoint(
GoogleMapServiceHelper.getCoordinateE6(latitude),
GoogleMapServiceHelper.getCoordinateE6(longitude));
getMapView().getController().animateTo(geoPoint);

Related

MapView start position

Good afternoon,
When i'm starting my application, the mapview is showed like you can see in the follow picture :
but i would like to start the mapview with some zoom in some point, something similar to this :
Which method i need to use?
Thanks in advance.
You add a zoom level to the map controller:
mapView.getController().setZoom(17); // an int that suits you
Read more about zoom levels here: https://developers.google.com/maps/documentation/staticmaps/#Zoomlevels
To set center you can use:
mapView.getController().setCenter(new GeoPoint(latitude,longitude));
set -
mapView.setStreetView(true);
mapView.getController().setZoom(17); // an int that suits you
mapView.getController().setCenter(new GeoPoint(latitude,longitude));
This is the solution.
for displaying egypt use it-
String coordinates[] = {"18.352566007", "73.78921587"};//here you can set geopoints of egypt
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));//p is GeoPoint
mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();

Android mapview geopoint difference emulator and device

i am getting data from gps provider using mylocation class. code is this:
MyLocation.LocationResult locationResult = new MyLocation.LocationResult() {
#Override
public void gotLocation(Location location) {
//Got the location!
// for phone
//currentLocation = new GeoPoint((int) (location.getLatitude() * 1000000),
// (int) (location.getLongitude() * 1000000));
// for emulator
currentLocation = new GeoPoint((int) (location.getLatitude()),
(int) (location.getLongitude()));
doSomething();
}
};
MyLocation myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
when i use the app in emulator(2.3.3) it shows the correct location without multiplying anything.
but when i use it in a device(4.0) lat and lon need to multiplied with 1000000. i couldn't find why. i don't think its because of the version of android. anyone have any idea?
Because the MapView uses microdegress for its units so you need to multiply by 1e6. Otherwise you show up off the coast of Africa - basically lat long of approximately 0,0
From the documentation on GeoPoint:
An immutable class representing a pair of latitude and longitude, stored as integer numbers of microdegrees.
Don't know why the emulator is working - it shouldn't.

Unable to find a Location Dynamically in Google-Map

I am facing a problem with the google map search. I have mad a app through which i can see a location in google map on my emulator which is set in the code as:
int lat = (int)(22.3666667*1000000);
int lng = (int)(91.8000000*1000000);
GeoPoint pt = new GeoPoint(lat,lng);
This works fine.
Now i want to search a location dynamically i.e. i have a editbox(Location_For_Search) and a button(Find_Location_Button). So when i write some location in editbox and press the button then it will show the location in google map with a marker on location. How can i do this?
Please any one help me.
With best wishes
Md. Fazla Rabbi
Use the geocoder:
Geocoder geo = new Geocoder(this);
List<Address> addr;
try
{
addr = coder.getFromLocationName(yourEditTextaddr, 10);
Address loc = addr.get(0);
loc.getLatitude();
loc.getLongitude();
point = new GeoPoint((int) (loc.getLatitude() * 1E6),
(int) (loc.getLongitude() * 1E6));
return point;
}

Need help regarding placement of map marker

I need your quick assistance for the problem stated below
In my android application I show a marker on specific location.
Here is my code
double latitude = Double.parseDouble(this.latitude);
double longitude = Double.parseDouble(this.longitude);
int latitudeE6 = (int) (latitude * 1e6);
int longitudeE6 = (int) (longitude * 1e6);
Log.i("Latitude","String = "+this.latitude+",Double = "+latitude+", int = "+latitudeE6);
Log.i("Longitude","String = "+this.longitude+",Double = "+longitude+", int = "+longitudeE6);
GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
Log.i("Point a", ""+point.getLatitudeE6()+","+point.getLongitudeE6());
OverlayItem overlay = new OverlayItem(point, title, detail);
Drawable drawable = mapView.getContext().getResources().getDrawable(
R.drawable.pin);
HelloOverlayItem helloOverLay = new HelloOverlayItem(drawable, this);
Log.i("Point b", ""+point.getLatitudeE6()+","+point.getLongitudeE6());
helloOverLay.addOverlay(overlay);
mapView.getOverlays().add(helloOverLay);
MapController controller = mapView.getController();
Log.i("Point c", ""+point.getLatitudeE6()+","+point.getLongitudeE6());
controller.animateTo(point);
controller.setCenter(point);
controller.setZoom(10);
I can get proper location integers in "Point C" log entry, which is not 0,0 (some where near London) But in map it always show me on 0,0 how can it be possible?? How to get rid of this??
I can't say that it's surely an answer or just a work around until it create some bug. But calling mapView.invalidate() worked. I have added this line exactly after mapView.getOverlays().add(helloOverLay); And it worked.

MyLocationOverlay doesn't appear

when I call this method the blue dot is not appearing on the map, until i send location from ddms,
then suddenly it appears.
private void findMyLocation(final Location location){
final MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
myLocationOverlay.enableMyLocation();
myLocationOverlay.enableCompass();
final GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
controller.animateTo(point);
controller.setCenter(point);
mapView.getOverlays().add(myLocationOverlay);
mapView.postInvalidate();
}
how can i show that blue dot right after calling this method?
thanks a lot.
how can i show that blue dot right after calling this method?
You can't.
MyLocationOverlay, as its name suggests, shows the user's location. If the device/emulator does not know the user's location, it cannot show it.
In the case of the device, it will not show the user's location until it has determined said location (e.g., GPS).
In the case of the emulator, it will not show the user's location until it has determined said location (e.g., DDMS).

Categories

Resources