Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
Need to get more zoom picture at loading first time
shawn peter
Ranch Hand
Posts: 1325
1
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
this is my map example.It is working fine..This is working fine.Anyway i need to get more zoom picture at first time.
package com.android.mymap; import java.io.IOException; import java.util.List; import android.graphics.drawable.Drawable; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class GMapsActivity extends MapActivity implements LocationListener{ private MapView mapView; private LocationManager locationManager; //private static final double latitudeE6 = 9.097416174598038 * 1E6; //private static final double longitudeE6 = 80.14439212158322 * 1E6; private static double latitudeE6 = 0.0; private static double longitudeE6 = 0.0; private OverlayItem overlayitem1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.map_view); mapView.setBuiltInZoomControls(true); mapView.setClickable(true); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); //Get the best provider for the criteria Criteria criteria = new Criteria(); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAccuracy(Criteria.ACCURACY_COARSE); String bestprovider = locationManager.getBestProvider(criteria,false); Location lastknownlocation = locationManager.getLastKnownLocation(bestprovider); longitudeE6=lastknownlocation.getLongitude()*1e6; latitudeE6 =lastknownlocation.getLatitude()*1e6; locationManager.requestLocationUpdates(bestprovider,5000, 0.2f, this); List<Overlay> mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.icon); CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay( drawable, this); //GeoPoint point = new GeoPoint((int)latitudeE6, (int)longitudeE6); GeoPoint point = new GeoPoint((int)latitudeE6,(int)longitudeE6); //OverlayItem overlayitem = new OverlayItem(point, "Hello","I'm in From Wadduwa, Sri lanka!"); Geocoder geocoder = new Geocoder(this); List<Address> addresses; try { addresses = geocoder.getFromLocation(lastknownlocation.getLatitude(),lastknownlocation.getLongitude(),1); for (Address address: addresses){ String Country=address.getCountryName(); overlayitem1 = new OverlayItem(point, address.getCountryName(), address.getAddressLine(0)); //locationdetails += "Address is "+address.getAddressLine(0)+" ,"+address.getCountryName(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //itemizedOverlay.addOverlay(overlayitem); itemizedOverlay.addOverlay(overlayitem1); mapOverlays.add(itemizedOverlay); MapController mapController = mapView.getController(); mapController.animateTo(point); mapController.setZoom(6); System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "+longitudeE6); System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "+latitudeE6); } @Override protected boolean isRouteDisplayed() { return false; } @Override protected boolean isLocationDisplayed() { return false; } @Override public void onLocationChanged(Location location) { longitudeE6=location.getLongitude()*1e6; latitudeE6=location.getLatitude()*1e6; } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } }
package com.android.mymap; import java.util.ArrayList; import android.app.AlertDialog; import android.content.Context; import android.graphics.drawable.Drawable; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.OverlayItem; public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> { private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>(); private Context context; public CustomItemizedOverlay(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } public CustomItemizedOverlay(Drawable defaultMarker, Context context) { this(defaultMarker); this.context = context; } @Override protected OverlayItem createItem(int i) { return mapOverlays.get(i); } @Override public int size() { return mapOverlays.size(); } @Override protected boolean onTap(int index) { OverlayItem item = mapOverlays.get(index); AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(item.getTitle()); dialog.setMessage(item.getSnippet()); dialog.show(); return true; } public void addOverlay(OverlayItem overlay) { mapOverlays.add(overlay); this.populate(); } }
shawn peter
Ranch Hand
Posts: 1325
1
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
this programm works fine.But when it runs it gives me a small map.I mean we have t ozoom many times to get the current location.Can any one tell me the way to improve the zooming level at first time ?
shawn peter
Ranch Hand
Posts: 1325
1
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Ok.I found it.Using below command
mapController.setZoom(17);
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
is there any way to trigger onLocationChanged other than moving
It prints me pointer repeatedly
how to add a google search option
street view & satilite view is not working
it doesn't show me map on emulator
More...