我有一个非常简单的SupportMapFragment来显示我在此视图中使用的小型Google地图

想法是用户可以单击它以查看全屏地图.如何摆脱地图上的+/-按钮?如果不可能,是否有另一种获取地图的方法?
这是我的MapFragment代码:
public class CustomMapFragment extends SupportMapFragment {
private static LatLng mPosFija;
public CustomMapFragment() {
super();
}
public static CustomMapFragment newInstance(LatLng position) {
CustomMapFragment fragment = new CustomMapFragment();
mPosFija = position;
return fragment;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getMap() != null) {
initMap();
Log.d(getClass().getSimpleName(), "Map ready for use!");
}
}
@Override
public void onResume() {
super.onResume();
initMap();
}
private void initMap() {
Log.v("CustomMapFragment", "initMap");
if (getMap() != null) {
UiSettings settings = getMap().getUiSettings();
settings.setAllGesturesEnabled(true);
settings.setMyLocationButtonEnabled(false); …Run Code Online (Sandbox Code Playgroud) 我有一个导航抽屉,其中Map是其他项目中的一个选项.当我点击我的地图时,它有效.如果我再次转到其他导航抽屉项目并返回地图,它会崩溃.谁能告诉我原因?
这是代码..
public class Map extends Fragment {
private GoogleMap mMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.map, container, false);
setUpMapIfNeeded();
return view;
}
@Override
public void onResume() {
super.onResume();
setUpMapIfNeeded();
}
@Override
public void onPause() {
super.onPause();
setUpMapIfNeeded();
}
@Override
public void onDestroy() {
super.onDestroy();
}
private void setUpMapIfNeeded() {
if (mMap == null) {
FragmentManager fm = getFragmentManager();
mMap = ((SupportMapFragment) fm.findFragmentById(R.id.map))
.getMap();
if (mMap != null) {
setUpMap();
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个通过 SupportMapFragment 显示地图的 android 应用程序。该应用程序在过去几个月运行良好,直到最近我将手机从 4.4.4 升级到 5.0(通过官方 OTA 更新)。现在应用程序崩溃了,我得到以下堆栈跟踪:
11-18 12:51:49.699 12594-12594/com.foo.bar E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.foo.bar, PID: 12594
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foo.bar/com.foo.bar.CallActivity}: android.view.InflateException: Binary XML file line #89: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #89: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) …Run Code Online (Sandbox Code Playgroud) crash android google-maps-android-api-2 supportmapfragment android-5.0-lollipop
我正在制作一个具有地图v2的应用程序,并且成功显示了多个图钉。我遵循了一个仅在地图v2上显示图钉/标记的教程。
通过服务,我得到了Marker的信息,该信息在地图上显示了Hotels的位置。服务正在向我发送包括酒店名称,位置,食物,服务,等级以及经纬度在内的信息。因此,让我解释一下到目前为止我所做的事情
我正在做的是在我的asynctask中获取每个酒店规范,在此我调用以下方法来添加标记
addMarker(Double.parseDouble(latitude), Double.parseDouble(longitude));
Run Code Online (Sandbox Code Playgroud)
addMarker函数如下:
public void addMarker(Double Lat,Double Long){
if (null != googleMap) {
MyMapFragment.this.googleMap.addMarker(new MarkerOptions()
.position(new LatLng(Lat, Long))
.title("You")
.draggable(true)
);
}
}
Run Code Online (Sandbox Code Playgroud)
这很好,因为它可以成功显示标记,但是我知道这不是正确的选择,因为我希望每个标记都显示其自身的其他特定信息,因此,为此,我知道我必须保存标记的信息,但是我不知道该怎么做
**我想要的是 **
我想要的是保存每个图钉/标记记录,并在该标记上单击以在新窗口或活动中打开其信息,因此,我该如何实现,请分享给我一个代码以获取提示,或者将我重定向到我确实知道有关github上的演示项目的简单代码,但由于它对我来说很复杂,因此我无法理解。请帮忙
我在我的代码中使用SupportMapFragment(class ="com.google.android.gms.maps.SupportMapFragment")作为地图.
当我将我的应用程序切换到黑暗或夜晚模式时,除了地图片段之外,一切都在黑暗中.
有没有办法在SupportMapFragment中使用暗模式?
谢谢.
我正在使用光模式地图
我想要下面的夜间模式地图
我在CollapsingToolbarLayout中有一个Google Map。尽管地图相机无法正常工作,但地图仍显示完美。
当您尝试滑动地图以移动到其他位置时,动画不流畅,并且通常不会注册滑动地图,因为CoordinatorLayout会覆盖地图。
这意味着当您尝试例如向上滑动地图时,地图不会滚动。而不是CoordinatorLayout滚动(NestedScrollView向上移动而不是Map更改位置)。
有谁知道如何解决这个问题?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
android:id="@+id/coordlayout"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="80dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:titleEnabled="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:padding="20dp"
android:background="@color/colorPrimary">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout">
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
android:src="@drawable/dots"
app:backgroundTint="#4fcd1e"
app:layout_anchor="@id/main.appbar"
app:layout_anchorGravity="bottom|right|end"
android:id="@+id/fab" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) 尽可能多的我得到以下错误:java.lang.noclassdeffounderror: com.google.android.gms.R$styleable尝试实现Android版地图时.
不知怎的,我一定错过了我做错了什么,因为它不起作用.我首先尝试将google-play-services.lib复制到lib文件夹中,但我看到某处我不应该这样做.
然后我尝试将addon-google_apis-google-8导入为项目,但该项目给出了错误 The import com.google cannot be resolved.
我正在关注Vogella教程:
活动:
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
map = fm.getMap();
//map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.btn_logo)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
Run Code Online (Sandbox Code Playgroud)
表现:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.testmap.test.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.testmap.test.permission.MAPS_RECEIVE" …Run Code Online (Sandbox Code Playgroud) maps android noclassdeffounderror mapfragment supportmapfragment
我已经将android SDK更新为5.0,而我之前的项目没有使用它(它在4.4.2中正常工作).
我有一个扩展片段的类
public class MapFragment extends Fragment{
//
}
Run Code Online (Sandbox Code Playgroud)
在这个课程中,我用google support mapfragment夸大了一个布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_tile_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" >
<RelativeLayout
android:id="@+id/full_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<Textview
<!-- dfh
fgh -->
/>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当我在我的代码中执行此操作时,它返回null
SupportMapFragment fragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
Run Code Online (Sandbox Code Playgroud)
在Android4.4.2中这条线路对我有用,但在更新后有一些问题......
有没有人找到解决方案......
今天,我的Eclipse崩溃了.因此,我重新创建了我的项目.
我没有更改代码,但它无法正常工作.
问题是当我使用SupportMapFragment getMap()函数时,我得到了一个
显示java.lang.NullPointerException.
这很奇怪,因为它在重新创建项目之前工作正常.代码如下:
public class MapFragment extends Fragment {
private static GoogleMap mMap;
private LocationManager locationManager;
private LocationListener locationListener;
private String mUserName;
private final static int DAY = 0;
private final static int MONTH = 1;
private final static int YEAR = 2;
private long timeFrom, timeTo, now;
private Button btnTimeChanger;
private int postion = 2;
private View view;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
FrameLayout fl = …Run Code Online (Sandbox Code Playgroud) android google-maps nullpointerexception fragment supportmapfragment