google-maps-android-api-2

Getting results of nearby places from User's Location using Google Maps API in Android

余生长醉 提交于 2019-11-27 07:08:54
This is the first time using google map API and google places API. I am doing a demo application that displays the list hospitals (for example) nearest to the user's location with routes to each of the hospitals. I been able to get the user's location with the code below the: public class MainActivity extends ActionBarActivity { private GoogleMap map; UiSettings mapSettings; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); if

Google map for android my location custom button

谁都会走 提交于 2019-11-27 06:50:29
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? 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.extensions.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" />

Google Maps Android API v2 - Sample Code crashes

房东的猫 提交于 2019-11-27 06:29:53
I'm trying to get the sample code of Android 'Google Maps Android API v2' working. I get the project built without errors. However, when I try to run the app on my Galaxy Nexus (connected with usb to my laptop), the app crashes immediately. I filled in my own Maps API Key at the AndroidManifest.xml I built against Android 4.1.2 This is the logging: Unable to resolve superclass of Lcom/example/mapdemo/BasicMapActivity; (66) Link of class 'Lcom/example/mapdemo/BasicMapActivity;' failed Could not find class 'com.example.mapdemo.BasicMapActivity', referenced from method com.example.mapdemo

Custom infowindow with google maps api v2

限于喜欢 提交于 2019-11-27 05:59:36
问题 I can customize the content of the infoWindow with a simple block of code: private GoogleMap mMap; mMap.setInfoWindowAdapter(new InfoWindowAdapter() { @Override public View getInfoWindow(Marker arg0) { return null; } @Override public View getInfoContents(Marker arg0) { View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null); return v; } }); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match

Android: Google Maps API - Change position of maps toolbar

≡放荡痞女 提交于 2019-11-27 05:32:18
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? 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 only. As Nathan said I should add some alternative if possible. So,There is a work around: You can disable the

SupportMapFragment.getmap() returns null

给你一囗甜甜゛ 提交于 2019-11-27 05:12:27
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.getMap(); mapMarker = map.addMarker(new MarkerOptions().position(new LatLng(0, 0)) .icon

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

点点圈 提交于 2019-11-27 04:27:46
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: <activity android:name="de.xbjoernx.gapp.MapsActivity"></activity> Error FATAL EXCEPTION: main java

Opening InfoWindow automatically when adding marker Google Maps v2 Android

一曲冷凌霜 提交于 2019-11-27 04:11:28
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))); 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 info window is displayed when a user taps on a marker if the marker has a title set. Only one info window is

duplicated id with fragment

浪子不回头ぞ 提交于 2019-11-27 04:01:17
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(13787): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 11-20 11:03:27.306: E

Android Maps API v2 draw circle

百般思念 提交于 2019-11-27 03:40:26
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 different part of the world: As you see circles are not really circles and even second one is ellipse