google-maps-android-api-2

Android Polyline - Adding point by point

会有一股神秘感。 提交于 2019-12-04 03:28:47
I'm currently having a map, and each 10 meters I use LocationListener to refresh my location and get the new Latitude and Longitude. Now I wish that the route the user is taking will be displayed with a red line. So everytime the OnLocationChange() from LocationListener class is called, I want to update the map with a line between the last location and the new location. So far I've added the following: private void initializeDraw() { lineOptions = new PolylineOptions().width(5).color(Color.RED); lineRoute = workoutMap.addPolyline(lineOptions); } during the OnLocationChanged I call this:

How do I get the coordinates of a map on tap with MapFragment (not MapView)?

本秂侑毒 提交于 2019-12-04 02:24:35
I have searched around on how to get the coordinates of a location when the map is tapped. However, most, if not all the examples require a MapView as a parameter. For example: public boolean onTap(GeoPoint p, MapView map){ if ( isPinch ){ return false; }else{ Log.i(TAG,"TAP!"); if ( p!=null ){ handleGeoPoint(p); return true; // We handled the tap }else{ return false; // Null GeoPoint } } } @Override public boolean onTouchEvent(MotionEvent e, MapView mapView) { int fingers = e.getPointerCount(); if( e.getAction()==MotionEvent.ACTION_DOWN ){ isPinch=false; // Touch DOWN, don't know if it's a

Geocoder.getFromLocationName() throws “Service not available” exception on Android 4 with Google Maps V2

ⅰ亾dé卋堺 提交于 2019-12-04 02:13:28
问题 The method Geocoder.getFromLocationName() throws the exception Service not available on Android 4.1, even if GooglePlayServicesUtil.isGooglePlayServicesAvailable() returns SUCCESS and Geocoder.isPresent() returns true . Is there any official example for geocoding in the new Google Maps v2 API? 回答1: Geocoder is not related to Google Maps Android API v2. You may want to use Google Geocoding API directly instead of Geocoder , which gives you limited amount of data and might be affected by device

How to get Google Maps object inside a Fragment

三世轮回 提交于 2019-12-04 00:53:45
I am using fragments in my application and I am new for this. There is a fragment in which I want to display Google Map and want to get its object, for this I have a fragment in my XML and I want to inflate it in the Fragment itself. When I am trying to inflate the map view its showing me error for getSupportFragmentManager(). How do I get the map object then that is the main issue. My XML is like this :- <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="250dp" class="com.google.android.gms.maps.SupportMapFragment" /> And my Fragment in which I want to

Using an Animated Gif as Ground Overlays in G. Maps v2

隐身守侯 提交于 2019-12-04 00:07:45
I am currently using Google Maps and would like to use an animated Gif as Overlay in my app. This is really frustrating as it seems very easy on iOS version of the app, SO I really want to achieve something cool. The result I would like to see is on 23s of this video: https://www.youtube.com/watch?v=JI323jA67x0#t=23s The Ground Overlays seems the bast practice, but doesn't accept animated gif: LatLng NEWARK = new LatLng(40.714086, -74.228697); GroundOverlayOptions newarkMap = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)) .position(NEWARK,

How do I zoom in automatically to the current location in Google Maps API for Android?

北慕城南 提交于 2019-12-03 23:33:37
I have integrated the Google Maps API in Android Studio, and it also finds the current location, but I want to increase the zoom level, so that I can view my current location more clearly and precised. How do I increase the zoom level? You can find my code below: package com.example.umar.testgoogle; import android.location.Location; import android.content.IntentSender; import android.location.Location; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.util.Log; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api

GoogleMap not showing the changes I made

北城余情 提交于 2019-12-03 22:59:51
问题 I have a fragment in which I use (or rather, want to use) Google Maps. The fragment is between an actionbar and a tabhost, the fragment's layout is <SeekBar android:id="@+id/search_map_seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="50" android:progressDrawable="@drawable/seekbar_progress" android:thumb="@drawable/seekbar_thumb" android:layout_marginTop="5dp"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap

App crashes with FragmentManager Replace when using GoogleMaps

只谈情不闲聊 提交于 2019-12-03 22:59:20
问题 I'm using the following code to load fragments depending on which item has been selected on NavigationDrawer, however the MapFragment contains Google Maps fragment inside of it and it crashes after trying to open it for the second time. Here's the code I'm using: @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); if (position == 0) { fragmentManager

How to link Google Maps Android API v2 Marker to an object

徘徊边缘 提交于 2019-12-03 22:34:11
问题 I'm adding dynamically a non-fixed amount of markers in a map, which each of them are related to one instance of my POCO class. I need to link them so when the user clicks on one of the markers, I show the rest of the data inside the custom InfoWindow. What do you suggest? PS: I add new markers everytime the user pans or zooms the map and I worried about overloading the app. Are the non visible markers disposed? 回答1: I suggest using a HashMap or something similar. As you iterate over your

get bounds of a location in google map android v2

一笑奈何 提交于 2019-12-03 22:30:53
Consider I have the LatLng of location A in the map. how can I get the Latlng of B and C position on the map? I want to get the bounds of the red box. EDIT: I want to get the bound of this box and limit the camera to that bound, so user can not change the camera and go outside this bound MaciejGórski The code I posted in this answer: MKCoordinateRegionMakeWithDistance equivalent in Android will get bounds for you. Usage: LatLngBounds bounds = boundsWithCenterAndLatLngDistance(centerPointPosition, 12000, 12000); // 12000 in meters This answers your original question about getting bounds. You