google-maps-android-api-2

Android: Google Maps location with low battery usage

耗尽温柔 提交于 2019-11-26 10:32:54
问题 My app is currently using Maps by Google Play Services speficying: mMap.setMyLocationEnabled(true); I realize each time I am displaying the map in my app: the location is indicated on the map by a blue dot a location icon is displaying in the top bar if I go into Settings/Location of the phone, my app is reported as \"High battery use\" However, I can see there are apps that use Maps and still show the location blue dot, but the location icon doesn\'t appear in top bar and their battery usage

Replace getMap with getMapAsync

做~自己de王妃 提交于 2019-11-26 10:30:51
I want to replace the deprecated getMap Method with getMapAsync , but I didn't use MapFragment but GoogleMap like this: private GoogleMap googleMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); try { if(googleMap == null) { googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); } googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); googleMap.setMyLocationEnabled(true); googleMap.setTrafficEnabled(true); googleMap.setIndoorEnabled(true); googleMap.setBuildingsEnabled(true);

Android: Google Maps API - Change position of maps toolbar

风流意气都作罢 提交于 2019-11-26 10:01:59
问题 I\'m using the Google Maps API for Android. The following code enables the maps toolbar in the bottom right corner when I click on a Marker googleMap.getUiSettings().setMapToolbarEnabled(true); However, I\'d like this maps toolbar to appear in the TOP RIGHT corner of the map, rather than the default bottom right position. How would I do this? 回答1: Thought of commenting, But has low reputation. So: As far as I know, there is no way to position it for now. It'll appear at its default position

How to animate marker in android map api V2?

泄露秘密 提交于 2019-11-26 09:21:47
问题 I want to implement smooth transition to emulate car marker moving on the map. Is it possible to animate marker in android map api v2? 回答1: Try out the below code to animate the marker on Google Map V2. You need to use the Interpolator class to apply the animation on the Marker and handle it in the Handler for the animation as below: public void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) { final Handler handler = new Handler(); final long start =

Google Maps API v2 SupportMapFragment inside ScrollView - users cannot scroll the map vertically

南笙酒味 提交于 2019-11-26 08:59:44
问题 I am trying to put a Google map inside a scroll view, so that the user can scroll down other contents to see the map. The problem is that this scroll view is eating up all the vertical touching events, so the UI experience of map becomes very weird. I know that in V1 of the google map, you could override onTouch, or setOnTouchListener to call requestDisallowInterceptTouchEvent upon MotionEvent.ACTION_DOWN. I have tried to implement the similar trick with V2 to no avail. So far I have tried:

How do I draw a route, along an existing road, between two points?

半城伤御伤魂 提交于 2019-11-26 08:53:24
问题 I want to show the driving route between two locations in my android app. I want to draw the route only on top of road segments. There are several answers on stack overflow itself, and all of them were using the same method. Get the directions from start point to destination using google directions API, and draw a polyline across the points returned. Following are some of the answers which uses this method. https://stackoverflow.com/a/17007360/1015678 https://stackoverflow.com/a/40563930

How to get current Location in GoogleMap using FusedLocationProviderClient

巧了我就是萌 提交于 2019-11-26 08:06:43
问题 I want to get periodic (say every 2 minutes) current location updates for this I\'m following official documentation, I wrote this code but its not giving current location updates every two minutes even specified in LocationRequest object that I\'m passing in requestLocationUpdates(), here is code: public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{ private

Android Google Maps API V2 Zoom to Current Location

主宰稳场 提交于 2019-11-26 08:05:22
问题 I\'m trying to mess around with the Maps API V2 to get more familiar with it, and I\'m trying to start the map centered at the user\'s current location. Using the map.setMyLocationEnabled(true); statement, I am able to show my current location on the map. This also adds the button to the UI that centers the map on my current location. I want to simulate that button press in my code. I am familiar with the LocationManager and LocationListener classes and realize that using those is a viable

Android Geocoder getFromLocationName always returns null

Deadly 提交于 2019-11-26 07:42:19
问题 I have been trying to geocode a string to get its coordinates but my program always crashes because when ever I try to use getFromLocationName() it returns null . I have been trying to fix this for hours but nothing is working. Here is my code public class MainActivity extends Activity { private GoogleMap mMap; List<Address> addresses; MarkerOptions miami; String myLocation = \"Miami,Florida\"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

How to handle onTouch event for map in Google Map API v2?

ぃ、小莉子 提交于 2019-11-26 06:40:58
问题 GoogleMap by default doesn\'t provide event for map drag start and drag stop. I have already reported that problem here. I want to make custom handler that will use plain onTouch event and combine it with setOnCameraChangeListener . However i failed to find how I can access onTouch event of GoogleMap object. It doesn\'t provide such callback . I wonder how can i handle onTouch event for map in Google Map API v2 ? 回答1: Here is a possible workaround for determining drag start and drag end