标签: android-maps-v2

自定义信息窗口适配器,具有map v2中的自定义数据

我想在android中的map v2中制作自定义信息窗口适配器,如下所示.

在此输入图像描述

我已经看到下面的链接,但没有得到更多.

1,2,3,

下面是我的内容布局文件.

<?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" 
>
    <ImageView
        android:id="@+id/infocontent_iv_image"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_alignParentTop="true" 
    />
    <RelativeLayout
        android:id="@+id/infocontent_rl_middle"
        android:layout_below="@id/infocontent_iv_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_margin="5dp"
    >

    </RelativeLayout>
    <TextView
        android:id="@+id/infocontent_tv_name"
        android:layout_below="@id/infocontent_rl_middle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" 
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_type"
        android:layout_below="@id/infocontent_tv_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#CCCCCC"
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_desc"
        android:layout_below="@id/infocontent_tv_type"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_addr"
        android:layout_below="@id/infocontent_tv_desc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
    />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

所以任何人都可以帮助我如何将数据设置为infowindow适配器中的所有视图?

android infowindow android-maps-v2

41
推荐指数
2
解决办法
8万
查看次数

Android:如何绘制路线方向谷歌地图API V2从当前位置到目的地

如何绘制从当前位置到目的地的路线方向(纬度和经度),我的代码如下:

import android.os.Bundle;
import com.actionbarsherlock.app.SherlockActivity;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class DetailMapActivity extends SherlockActivity {
    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_detail_map);

        LatLng TO_DESTINATION = new LatLng(-6.33438, 106.74316);

        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
        map.setMyLocationEnabled(true);

        map.addMarker(new MarkerOptions().position(TO_DESTINATION).title("Destination Title")
                .snippet("Destination Description"));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(TO_LOCATION, 40));

        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

我想通过提供商网络或gps从当前位置绘制,然后通过驾驶到目的地绘制路线.

我正在使用android google apis V2.

谢谢你的帮助.

android android-maps-v2

32
推荐指数
2
解决办法
9万
查看次数

Android Map V2 - 为什么选择MAPS_RECEIVE权限

将此视为维基问题.

当我设置我的项目以支持Map V2时,已经有一个步骤来添加MAPS_RECEIVE权限.

<permission
          android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE"/>
Run Code Online (Sandbox Code Playgroud)

为什么我们从应用程序本身创建和使用权限?

谷歌播放服务应用程序是否使用此权限进行交互?

这个权限不能照顾这些东西吗?

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Run Code Online (Sandbox Code Playgroud)

我认为使用自定义权限是为了允许其他应用启动/使用我们应用的服务/资源.

android android-maps-v2

32
推荐指数
3
解决办法
2万
查看次数

是什么让我的地图片段加载缓慢?

绩效提升:

以前我将所有图像保存在drawable文件夹中,这可能是地图首次加载缓慢的原因,当在屏幕上绘制标记时,图像可能不适合屏幕大小.现在我保存了图像drawable-mdpi,drawable-hdpi等等,应用程序比以前更顺畅.希望能帮助到你

原始问题:

我在片段中创建了一个地图,源代码可以在下面找到.

第一次加载时,地图片段缓慢.如果我再去任何其他片段并再次点击地图片段,它就会加载得很快而且没有slug.

谁能告诉我这里发生了什么?谢谢!

fragment_map.xml,id是 map

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:map="http://schemas.android.com/apk/res-auto"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>
Run Code Online (Sandbox Code Playgroud)

MyMapFragment.java(包含onCreateViewsetUpMapIfNeeded)

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    try {
        rootView = inflater.inflate(R.layout.fragment_map, container, false);
    } catch (InflateException e) {
    /* map is already there, just return view as it is */
        Log.e(TAG, "inflateException");
    }

     setUpMapIfNeeded();

    return rootView;
}


public void setUpMapIfNeeded() …
Run Code Online (Sandbox Code Playgroud)

android android-maps android-maps-v2

31
推荐指数
3
解决办法
2万
查看次数

mapFragment.getMapAsync(this) - NullPointerException

我使用的com.google.android.gms:play-services-maps:7.5.0是谷歌地图服务版本.当试图打电话给下面我得到java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this); //error

    return inflater.inflate(R.layout.fragment_example_map, container, false);
}
Run Code Online (Sandbox Code Playgroud)

fragment_example_map.xml文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="app.ExampleMap">

    <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"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

android google-maps android-maps-v2

31
推荐指数
6
解决办法
6万
查看次数

AndroidRuntime: 致命异常: androidmapsapi-ZoomTableManager, java.lang.ArrayIndexOutOfBoundsException: length=1; 指数=12

我在我的应用程序中使用了 Google Maps SDK (v2),今天突然它开始崩溃并显示以下崩溃消息:

2020-04-24 02:26:40.874 22678-22758/com.**.**E/AndroidRuntime: FATAL EXCEPTION: androidmapsapi-ZoomTableManager
Process: com.**.**, PID: 22678
java.lang.ArrayIndexOutOfBoundsException: length=1; index=12
    at com.google.maps.api.android.lib6.gmm6.vector.ct.<init>(:com.google.android.gms.dynamite_mapsdynamite@201216081@20.12.16 (120400-0):9)
    at com.google.maps.api.android.lib6.gmm6.vector.cv.a(:com.google.android.gms.dynamite_mapsdynamite@201216081@20.12.16 (120400-0):23)
    at com.google.maps.api.android.lib6.gmm6.util.m.run(:com.google.android.gms.dynamite_mapsdynamite@201216081@20.12.16 (120400-0):14)
    at java.lang.Thread.run(Thread.java:919)
Run Code Online (Sandbox Code Playgroud)

有没有人以前遇到过这个问题。如果获得解决此致命异常问题的帮助,将会非常有帮助。

android google-maps android-maps-v2

31
推荐指数
3
解决办法
3254
查看次数

在Google Maps API v2中更改标记大小

我正在尝试将我的应用移植到全新的Google Maps API v2,但无法找到如何更改标记的大小(我的某些标记小于默认值).

在v1中,我使用了DrawablesetBounds()在将其添加到地图之前缩放的内容.

但现在,在v2中,我无法使用Drawable.我要使用MarkerOptions().icon(),只需要一个BitmapDescriptor(用a生成BitmapDescriptorFactory).

查看参考资料,似乎没有任何支持设置或更改BitmapDescriptor大小.

那么,我错过了什么,或者在这个API版本中设置自定义标记的大小根本不可能?

android android-maps-v2

30
推荐指数
4
解决办法
6万
查看次数

如何在Android Map v2上更改标记的位置

我需要做以下事情:我在地图上有一个标记,我需要改变它的位置.所以我尝试了以下方法:

MarkerOptions a = new MarkerOptions()
            .position(new LatLng(50,6)));
        map.addMarker(a);
        a.position(new LatLng(50,5));
Run Code Online (Sandbox Code Playgroud)

地图是一个GoogleMap.我想我必须刷新地图或平等吗?

android android-maps-v2

28
推荐指数
4
解决办法
5万
查看次数

Android Google Map API V2:打开Marker右侧的自定义信息窗口

我已经为Android集成了Google MAP API V2.我希望在My Marker的Onclick上有一个自定义信息窗口.到目前为止还可以.我整合了它.

我想要的是:我想在标记的右侧显示我的自定义信息窗口而不是标记的顶部.

以下是我正在使用的代码:

public class MainActivity extends FragmentActivity {

    private MainMapFragement mapFragment;
    private HashMap<Marker, EventInfo> eventMarkerMap;


    Marker ThirdMarker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mapFragment = new MainMapFragement();
        // FragmentTransaction ft = getFragmentManager().beginTransaction();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.map, mapFragment);
        ft.commit();

    }

    @Override
    protected void onStart() {
        super.onStart();
        setUpEventSpots();
    }

    private void setUpEventSpots() {
        // I'm going to make 2 EventInfo objects and place them on the map
        EventInfo firstEventInfo = new EventInfo(new LatLng(50.154, …
Run Code Online (Sandbox Code Playgroud)

android google-maps infowindow android-maps-v2

28
推荐指数
2
解决办法
1万
查看次数

Android中的'debug.keystore'和'release.keystore'有什么区别?

最近,我正在使用Android Maps V2.我碰到debug.keystorerelease.keystore.他们之间有什么区别?为什么我们必须同时使用?

android android-maps-v2

26
推荐指数
4
解决办法
2万
查看次数