标签: android-maps-v2

如何在Google Maps V2中启用特定路线的交通信息?

Google导航仅显示给定路线的流量图层.随着GoogleMap.setTrafficEnabled(true)我会为整个地图的交通信息.

我知道如何从Google Directions中为路线绘制折线,但是如何才能为该路线打开流量图层?

android android-maps-v2

5
推荐指数
1
解决办法
5478
查看次数

是否可以通过编程方式设置Android Maps API v2密钥?

是否可以以编程方式设置API v2密钥,而不是在AndroidManifest文件中设置此值?

我能够使用API​​ v1键执行此操作,但我无法在MapView使用当前API执行此操作时找到一些方法构造函数.

android android-maps-v2

5
推荐指数
1
解决办法
2840
查看次数

Android GoogleMap或SupportMapFragment - 空指针异常

在我的应用程序中我在片段中显示谷歌地图版本2.但我得到Null指针异常

mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

这是我的完整代码:

    public class SearchResultMap extends Fragment{

    private GoogleMap mMap;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View fragmentView = inflater.inflate(R.layout.map, container, false);

        mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); // line no : 28

         mMap.addMarker(new MarkerOptions() .position(new LatLng(xxxxxx,xxxxxx)) .title("Current Location")
         .icon(BitmapDescriptorFactory.fromResource(R.drawable.ball_pointer))
         .snippet("xxxxx"));

        return fragmentView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

}
Run Code Online (Sandbox Code Playgroud)

XML:

<LinearLayout 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/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> …
Run Code Online (Sandbox Code Playgroud)

android android-maps google-play-services supportmapfragment android-maps-v2

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

地图v2标记动画 - 淡入淡出

如何淡入和淡出GoogleMap 标记

这是我向地图添加标记的方法:

    marker = map.addMarker(new MarkerOptions()
            .position(point)
            .title(title)
            .snippet(text)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
    );
Run Code Online (Sandbox Code Playgroud)

android android-animation android-mapview android-maps-v2

5
推荐指数
2
解决办法
3885
查看次数

在运行时重新调整地图大小

我想通过单击箭头键在运行时动态调整我的地图大小.我的布局是:

<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MapActivity" >

<fragment
 android:id="@+id/map"
 android:name="com.google.android.gms.maps.MapFragment"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_alignParentLeft="true"
 android:layout_alignParentRight="true"
 android:layout_alignParentTop="true" />
Run Code Online (Sandbox Code Playgroud)

我想我必须使用MapView和setLayoutParams,但我不确定如何.有人可以帮我怎样做吗?提前致谢.

android android-maps-v2

5
推荐指数
2
解决办法
4810
查看次数

如何使用map apiv2或map api v3在android中进行markererclusterer

并告诉我正确的模拟器规范...它可以是模拟器的错误......

我试过通过以下链接

https://www.google.co.in/?gws_rd=cr&ei=iCf5Upm7KsWXrAedkoCoDg#q=marker+cluster+example+in+android
http://karnshah8890.blogspot.in/2013/04/clustering-on-google-map-v2.html
https://developers.google.com/maps/documentation/android/utility/marker-clustering
https://developers.google.com/maps/documentation/android/utility/marker-clustering
http://stackoverflow.com/questions/7447350/android-maps-point-clustering
http://stackoverflow.com/questions/14204554/google-maps-marker-clusters-in-android
https://github.com/twotoasters/clusterkraf/
https://github.com/nodesagency-mobile/Android-Google-Map-V2-Sample
https://github.com/googlemaps/android-maps-utils/tree/master/demo/src/com/google/maps/android/utils/demo/model
https://github.com/Bersh/MarkersCluster/blob/master/res/menu/activity_main.xml
https://github.com/damianflannery/Polaris/blob/clustering/sample/src/com/cyrilmottier/android/polarissample/util/Config.java
http://umut.tekguc.info/en/content/google-android-map-v2-step-step
http://stackoverflow.com/questions/15495171/cluster-markers-in-google-maps-android-v2/15510054#15510054
Run Code Online (Sandbox Code Playgroud)

我正在尝试构建需要标记聚类的应用程序,所以我已经尝试了很多次阅读Google API创建演示但每次显示错误都建议我也是Web应用程序使用map API v3聚类标记哪个API我必须使用API​​ v2或apiv3的地图来构建应用程序,请帮助我,我是Android新手或给我一些链接,我可以找到我的解决方案

.............................mainactivity class..........................................

    package com.example.cluster;

    import java.util.ArrayList;

    import java.util.LinkedHashMap;
    import java.util.concurrent.ExecutionException;

    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Point;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.Menu;

    import com.example.demo.MarkerClusterizer;
    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.BitmapDescriptorFactory;
    import com.google.android.gms.maps.model.CameraPosition;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.MarkerOptions;

    public class MainActivity extends FragmentActivity {
         private ArrayList<MarkerOptions> markers = new ArrayList<MarkerOptions>();
            private Bitmap markerImage;
            private float oldZoom = 0;
            private GoogleMap …
Run Code Online (Sandbox Code Playgroud)

android google-maps-api-3 android-maps android-mapview android-maps-v2

5
推荐指数
1
解决办法
1105
查看次数

Android PlacePicker搜索

我创建了一个活动,让用户使用PlacePicker选择一个地方.但是,此处没有搜索功能.

我可以设置任何标志告诉PlacePicker Intent包含搜索栏吗?

android google-play-services android-maps-v2

5
推荐指数
0
解决办法
263
查看次数

使用XML在android中绘制自定义形状

我正在为android地图视图添加自定义标记.这是我正在使用它的图像.看起来像放置更多的标记大约100整个应用程序变慢.这是我正在使用的图像.

在此输入图像描述

我计划将此图像绘制为XML中的形状,而不是使用此图像.怎么做?

我也按照本教程 显示自定义标记.这个自定义绘图是否延迟了应用程序?

什么是最好的方法呢?

android android-maps-v2 android-shape

5
推荐指数
1
解决办法
7401
查看次数

在API级别19到22的android中检索当前位置

我在项目中使用下面的代码来检索用户的当前位置.但是,这似乎适用于我的API级别23的测试设备,但在我的API级别19到22的测试设备上不起作用.对位置的请求将返回null,因此将我放在坐标0,0 ..

如何获得API级别19到22的正确坐标?

package be.enventorslab.pingvalue;

import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import be.enventorslab.pingvalue.functions.Functions;

public class NearbyLocationActivity extends AppCompatActivity
        implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener,
        LocationListener {

        public static final String TAG = NearbyLocationActivity.class.getSimpleName();

        private final static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000;

        private GoogleMap mMap;

        private GoogleApiClient mGoogleApiClient;
        private LocationRequest mLocationRequest;

        Bundle bundle;

        @Override
        protected void onCreate(Bundle …
Run Code Online (Sandbox Code Playgroud)

android google-api-client android-maps-v2

5
推荐指数
0
解决办法
402
查看次数

如何在模拟器上显示地图

在Android Studio中,我创建了一个Map Activity项目。因此,没有自定义代码。

唯一的自定义更改是从google_maps_api.xml _(https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=) _ 复制URL 并使用它来创建API密钥。

Android Studio:3.0.1仿真器:具有API 25的Nexus 5X

Build.gradle文件

应用插件:“ com.android.application”

应用插件:“ kotlin-android”

应用插件:“ kotlin-android-extensions”

android {
    编译版本26
    defaultConfig {
        applicationId“ xxxx.xxx.xxxx”
        minSdkVersion 19
        targetSdkVersion 26
        版本代码1
        versionName“ 1.0”
        testInstrumentationRunner“ android.support.test.runner.AndroidJUnitRunner”
    }
    buildTypes {
        发布 {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}

依赖项{
    实现fileTree(dir:'libs',包括:['* .jar'])
    实现“ org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version”
    实施'com.android.support:appcompat-v7:26.1.0'
    实施'com.google.android.gms:play-services-maps:11.0.0'
    testImplementation'junit:junit:4.12'
    androidTestImplementation'com.android.support.test:runner:1.0.1'
    androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1'
}

屏幕截图

在此处输入图片说明

好像我在想什么。我只是不知道那是什么。

android android-maps-v2 android-studio

5
推荐指数
1
解决办法
447
查看次数