google-maps-android-api-2

Map view following user - MyLocationOverlay type functionality for Android Maps API v2

南楼画角 提交于 2019-11-26 19:06:22
问题 I switched to v2 of Maps for Android, and I am trying to port over the following functionality: With MyLocationOverlay I can show the devices current location (Blue Dot). When the user's location changes and the dot reaches the edge of the visible area, the map animates out so the dot becomes the center of the view, in real time. In v2, I am using SupportMapFragment with getMap().setMyLocationEnabled(true). The current location appears as a blue dot(arrow), but when the device changes

How to convert a LatLng and a radius to a LatLngBounds in Android Google Maps API v2?

醉酒当歌 提交于 2019-11-26 19:06:08
问题 I believe this is a limitation of the recent Google Maps API v2. They have recently added the ability to draw a Circle on the ground - but if you want to position the camera such that it shows the entire Circle, there exists no way to do so. One can call CameraUpdateFactory#newLatLngBounds(bounds, padding) where "bounds" is a LatLngBounds and "padding" is a distance in pixels. The issue is that there is no way to create a LatLng and a radius into a LatLngBounds. The constructor for

Google Maps Android API v2 very slow when adding lots of Markers

北城以北 提交于 2019-11-26 18:59:28
问题 I am updating an existing Android app to use the new Google Maps Android API v2. I have about 2500 markers that I want to add to the map. With the older version of the API I found the responsiveness of the maps to be horrendous when there are 2500 markers, so I had to work around it by only adding markers that are in the current visible region of the map. I was hoping 2500 markers would be faster with the new API, but it's still awful, even on a Nexus 4, and I'm not seeing any sort of option

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

元气小坏坏 提交于 2019-11-26 18:55:01
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 ? AZ13 Here is a possible workaround for determining drag start and drag end events: You have to extend SupportMapFragment or MapFragment . In onCreateView() you have to wrap your

Move all the markers on the map to their updated/new current location periodically as users moves

筅森魡賤 提交于 2019-11-26 18:38:22
问题 I'm developing an android app where some users opens the same activity from their devices. There is a map in this activity and as users opens this activity from their devices, their location coordinates is fetched from Firebase and a marker based on these coordinates is shown on the map. Here's my code: acceptingUserReference.child(requestID).child(key).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot

Is it possible to use Maps and place API with same API KEY

China☆狼群 提交于 2019-11-26 18:34:24
问题 I was tiring to build an app which uses google maps for showing places and Pace API for searching places. but it is not being possible to build the app with two different API keys in the manifest. So, I want to Know if it is possible to access both Maps and Place API with the same API key..? or There is some other way for doing this. 回答1: Yes! you can use same key on both of and also you can use only one key for all Google API See below image in listed all google api and see this link. Now

Check if a latitude and longitude is within a circle

試著忘記壹切 提交于 2019-11-26 18:00:31
问题 See this illustration: What I would like to know is: How to create an area (circle) when given a latitude and longitude and the distance (10 kilometers) How to check (calculate) if a latitude and longitude is either inside or outside the area I would prefer if you can give me code example in Java or specifically for Android with Google Maps API V2 回答1: What you basically need, is the distance between two points on the map: float[] results = new float[1]; Location.distanceBetween

Manage Google Maps API Key with Gradle in Android Studio

我怕爱的太早我们不能终老 提交于 2019-11-26 17:57:44
问题 I know Gradle is powerful and I would like to manage the API keys for development/produciton of Google Maps Currently I always need to manually comment one line and uncomment the other to make it work. Is there a way to do it automatically in Gradle with some custom release configuration ? <!-- MapView v2 API --> <uses-library android:name="com.google.android.maps" /> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="[MY_DEV_KEY]" /> <!-- PROD <meta-data android:name

Google Maps API v2 draw part of circle on MapFragment

笑着哭i 提交于 2019-11-26 17:38:51
I need to draw something like this which will be painted and have little transparency Also it needs to be clickable (onTouch event etc) I know that in API v1 you have to use Overlay and extend it using canvas and some mathematics. What is easiest way to do it in Google Map API v2? PS: Radius is variable. (For further reference) EDIT 1: I implemented CanvasTileProvider subclass and override its onDraw() method: @Override void onDraw(Canvas canvas, TileProjection projection) { // TODO Auto-generated method stub LatLng tempLocation = moveByDistance(mSegmentLocation, mSegmentRadius, mSegmentAngle)

Android Google Maps Direction Api - Api key restriction not working

北慕城南 提交于 2019-11-26 17:14:03
问题 When we are setting a Key restriction to NONE for Google Maps Direction Api, It works fine. But When we set Key restriction to Android apps and provide a proper Package name & SHA-1 certificate - It says Request Declined from Google Api response. Any known solution to this? 回答1: Directions API is a web service. The restrictions that will work with an API keys for web services are IP restrictions. It is supposed that web services requests are executed on your backend servers. If you need to