google-maps-android-api-2

What does map.setMyLocationEnabled(true) really do

本秂侑毒 提交于 2019-12-03 05:31:21
I am setting: map.setMyLocationEnabled(true) But I am wondering what this really does. What I know: I get a locate me button in the upper right corner of the map I get a blue icon on the map that represents my current location Here is my concern. I am writing a location aware app but I am concerned about battery. Elsewhere in my app (via preferences) I set up a LocationManager and listen for location events so I can log them. But part of my preferences is the accuracy at which I get updates and the interval. When I turn off my LocationManager: locationManange.removeUpdates(LocationListener

Add bounds to map to avoid swiping outside a certain region

核能气质少年 提交于 2019-12-03 05:26:01
问题 My app shows a map and i want that users can't swipe over a certain region. So i'm trying to add bounds but it makes the app to crash. Here is the working code: public class MapViewer extends Activity implements OnInfoWindowClickListener { private LatLng defaultLatLng = new LatLng(42.564241, 12.22759); private GoogleMap map; private int zoomLevel = 5; private Database db = new Database(this); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Adding custom property to marker (Google Map Android API V2)

点点圈 提交于 2019-12-03 04:23:12
问题 When using Google Map API V3 I can add custom property in the following way: var marker = new google.maps.Marker({ position: userLocation, map: myGoogleMap, animation: google.maps.Animation.DROP, icon: avatar, title: userName, customProperty1: bla, customProperty2: bla, customProperty3: bla, ... }); I'm wondering if I can do the same for API V2 Android, the reason I want to do this is that each info window of each marker need to know some information of that marker. And I'm trying to achieve

drawing driving routes using waypoints on android ( Google maps, Google direction api, json parsing, decode google polyline)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 03:57:34
drawPath() is used to draw polyloine on map. public void drawPath(String result){ try { final JSONObject jsonObject = new JSONObject(result); JSONArray routeArray = jsonObject.getJSONArray("routes"); JSONObject routes = routeArray.getJSONObject(0); JSONObject overviewPolylines = routes.getJSONObject("overview_polyline"); String encodedString = overviewPolylines.getString("points"); String statusString = jsonObject.getString("status"); Log.d("test: ", encodedString); List<LatLng> list = decodePoly(encodedString); LatLng last = null; for (int i = 0; i < list.size()-1; i++) { LatLng src = list

Get current location in onMapReady in android using google locations API

百般思念 提交于 2019-12-03 03:19:44
I'm trying to display the current location of the user on the google map inside my app but I don't want to keep updating the location as the user moves. His initial location should be recorded and showed until he closes the app. I have written the following code for this: private GoogleMap mMap; protected GoogleApiClient mGoogleApiClient; Location mLastLocation; double lat =0, lng=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); buildGoogleApiClient(); // Obtain the SupportMapFragment and get notified

Multiple markers with text on Android Google Maps API v2

纵然是瞬间 提交于 2019-12-03 03:14:47
My goal is to have multiple markers with text on each on the Android Google Maps API v2 map. The info windows approach (showInfoWindow()) is not suitable, because only one info window is displayed at a time. For example I want to have something like this: As you can see each marker has its own data (number for this example) displayed all the time. How can I achieve this with Android Google Maps API v2 ? to do that you'll have to customize the icon of each individual marker to be what you need. Here's the link: https://developers.google.com/maps/documentation/android/marker#customize_a_marker

google maps api v2 out of memory error

心不动则不痛 提交于 2019-12-03 01:45:39
i have a huge memory problem in my app. i am using google map api v2 with ClusterManager and custom markers. i supply an image via call to markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap)); for each marker based on its category. the problem is: after several screen rotations my app crashes because of OOM error: 05-14 11:04:12.692 14020-30201/rokask.rideabike E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 4194316 byte allocation with 1627608 free bytes and 1589KB until OOM" 05-14 11:04:12.722 14020-30201/rokask.rideabike E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 19179

Remove previous Marker and add new Marker in Google Map v2

你离开我真会死。 提交于 2019-12-03 01:31:22
I want to remove a current marker after long click on map anywhere and recreate a new marker at that point. I have cleared google map on long click on map and new marker is created but the previous marker also displayed. My Code is: public class EditLocation extends Fragment { View v; Context c; GoogleMap MAP; Button back; int loc; String lat; boolean isTapped = true; public EditLocation(Context c, int location, String latitude) { // TODO Auto-generated constructor stub this.c = c; this.loc = location; this.lat = latitude; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup

Error package `com.google.android.gms…` doesn't exist

北战南征 提交于 2019-12-03 01:10:12
I am new to Android development. I am learning to use Parse.com backend service and get stuck early on. I am following tutorial to create application that uses Google Maps Android API v2 . What I've done : download sample project from parse Import AnyWall-android\Anywall folder from downloaded project to Android Studio Rebuild project Then I get a bunch of errors here : import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesClient; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.location

How to reverse Geocode in google maps api 2 android

半城伤御伤魂 提交于 2019-12-03 00:41:12
I want to do reverse geocoding in my app using map api 2.But i dont know exactly how to do that?Any ideas? ianhanniballake Use Geocoder : Geocoder geoCoder = new Geocoder(context); List<Address> matches = geoCoder.getFromLocation(latitude, longitude, 1); Address bestMatch = (matches.isEmpty() ? null : matches.get(0)); Raja Jawahar You can do reverse-geocoding in two ways Geocoder Google API Geocoder It should be executed in a separate thread: private class FindPlaces extends AsyncTask<String, Void, List<Address>> { @Override protected List<Address> doInBackground(String... params) { if (act ==