google-maps-android-api-2

SupportMapFragment.getmap() returns null

拜拜、爱过 提交于 2019-11-26 12:47:11
问题 I\'m trying to load SupportMapFragment dynamically in a fragment, here is my onCreateView() method: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View contentView = inflater.inflate(R.layout.frag_map_layout, null); shopDtos=ShopListFragment.shopDtos; fragment =SupportMapFragment.newInstance(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.map_content, fragment); ft.commit(); map = fragment

Android: automatically choose debug/release Maps v2 api key?

那年仲夏 提交于 2019-11-26 12:18:50
问题 I\'m using Google Maps v2 API in my project. In Google Maps v2 the debug/release API key is defined in AndroidManifest.xml . I have seen the link but in that map key is defined in a xml layout file not in AndroidManifest.xml . So can I define both debug and release keys for my project in AndroidManifest.xml ? I want something like this in AndroidManifest.xml : If debug mode: <meta-data android:name=\"com.google.android.maps.v2.API_KEY\" android:value=\"@string/debug_map_api_key\"/> If release

Google map for android my location custom button

本小妞迷上赌 提交于 2019-11-26 12:12:09
问题 How can I change google map my location default button? I set my location enable and map draw standard image to find location, is it possible to change default image? 回答1: See below xml file to custom button: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:id="@+id/maps" android:name="pl.mg6.android.maps

Android map v2 zoom to show all the markers

喜夏-厌秋 提交于 2019-11-26 11:26:35
I have 10 markers in the GoogleMap . I want to zoom in as much as possible and keep all markers in view? In the earlier version this can be achieved from zoomToSpan() but in v2 I have no idea how about doing that. Further, I know the radius of the circle that needs to be visible. andr You should use the CameraUpdate class to do (probably) all programmatic map movements. To do this, first calculate the bounds of all the markers like so: LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Marker marker : markers) { builder.include(marker.getPosition()); } LatLngBounds bounds =

Blue dot and circle is not shown on MyLocation using android fused location api

六眼飞鱼酱① 提交于 2019-11-26 11:23:57
I was using LocationManager to track the user current location, Now after changing location manager to FusedLocation API, the blue dot and circle is not shown even after setting map.setMyLocationEnabled(true) . I can see the current location icon on top right corner in my map fragment but clicking on it does nothing. I reverted my code to LocationManager now i am able to see the blue dot pointing to my current location. what could be wrong using Fused Location API. Daniel Nugent For targeting api-23 or higher See this answer.... For targeting api-22 and lower: This code works for me, it has

Error: MapFragment cannot be cast to android.support.v4.app.Fragment

a 夏天 提交于 2019-11-26 11:11:19
问题 First, I watched out here: Start FragmentActivity from Activity and now I have the following problem: MapsActivity: public class MapsActivity extends FragmentActivity { private GoogleMap mMap; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maps); setUpMapIfNeeded(); } ... and want to start it out of the MainActivity with: startActivity(new Intent(this, MapsActivity.class)); The activity is registered in Android Manifest:

Opening InfoWindow automatically when adding marker Google Maps v2 Android

倖福魔咒の 提交于 2019-11-26 11:06:29
问题 Is there a way to open the infowindow automatically when we add a marker? Using this code to add the marker but infowindow only opens when clicking the marker: myMap.addMarker(new MarkerOptions() .position(latLng) .title(\"Title\") .snippet(\"Snippet\") .icon(BitmapDescriptorFactory .fromResource(R.drawable.marker))); 回答1: According to the documents of Google Maps for Android V2: An info window allows you to display information to the user when they tap on a marker on a map. By default, an

duplicated id with fragment

非 Y 不嫁゛ 提交于 2019-11-26 10:59:37
问题 I\'m trying to applicate drawernavigation (my first fragment is a map & the others are just some fragments with simple layouts).So it runs fine & I can navigate between my fragments but when I return to the first fragment which is a map I got a crash logcat: 11-20 11:03:27.306: E/AndroidRuntime(13787): FATAL EXCEPTION: main 11-20 11:03:27.306: E/AndroidRuntime(13787): android.view.InflateException: Binary XML file line #6: Error inflating class fragment 11-20 11:03:27.306: E/AndroidRuntime

Android Maps API v2 draw circle

旧巷老猫 提交于 2019-11-26 10:54:31
问题 Having the following code to draw circle (taken from Google Play Services \"maps\" sample): PolylineOptions options = new PolylineOptions(); int radius = 5; //What is that? int numPoints = 100; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + radius * Math.sin(i * phase), SYDNEY.longitude + radius * Math.cos(i * phase))); } int color = Color.RED; mMap.addPolyline(options .color(color) .width(2)); This is what gets drawn on

Display toolbar for Google Maps marker automatically

夙愿已清 提交于 2019-11-26 10:35:51
问题 I have a marker and when I open the map it shows the marker. When I click on it it shows the title and a toolbar which includes two buttons on the bottom right of the map which let me launch intents to navigate to the marker or show it in google maps. I would like to have these displayed automatically when the map is opened rather than having the user to click on the marker. Like this :-) ... I can\'t seem to work out how to do this. I have tried: // create marker MarkerOptions marker = new