问题
当应用程序启动时,它会显示一个白色的谷歌地图(我可以看到谷歌标志),即使在互联网连接良好的情况下等待几分钟也不会加载图块。
但是,如果我触摸屏幕,瓷砖开始出现(每次触摸一个瓷砖)。
我用 3 部实体手机进行了测试,得到了相同的结果。
地图活动
public class MapActivity extends Activity {
private MapView mMapView;
private GoogleMap gmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(savedInstanceState);
gmap = mMapView.getMap();
gmap.getUiSettings().setMyLocationButtonEnabled(false);
gmap.getUiSettings().setZoomControlsEnabled(false);
gmap.getUiSettings().setCompassEnabled(false);
gmap.getUiSettings().setAllGesturesEnabled(false);
gmap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
MapsInitializer.initialize(mMapView.getContext());
}
}
Run Code Online (Sandbox Code Playgroud)
布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/frameLayout">
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
显化
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nst.lazzus" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission …Run Code Online (Sandbox Code Playgroud) 我试图限制用户超出指定的城市边界。maxBounds在传单中,我通过地图对象的属性或setMaxBounds通过提供southwest&点的功能实现了这一点northeast。,这样它就限制了滚动/缩放超出该城市边界。
有没有像上面这样的方法来限制android中谷歌地图的滚动/缩放?
大家好,在 android v2 地图上做一个示例项目以设置当前位置。我遇到了几行
//what does this line do?
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//this line will animate to the provided lat and lon values
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()), 16.0f));
Run Code Online (Sandbox Code Playgroud)
mMap.moveCamera 有什么作用?与另一条线相比,我没有看到任何明显的视觉变化。两者的主要区别是什么?moveCamera 似乎类似于 animateCamera IMO。
我在将android地图集成到片段中时遇到问题。我知道如何在活动中执行此操作,但是此站点上的片段引用非常老,并且在2018年无法正常工作。我没有任何错误。下面是片段文件。任何帮助将不胜感激。我添加了API密钥和正确的清单文件。
package com.example.narmail.truck30mint.Api.Fragments;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.narmail.truck30mint.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
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 java.util.ArrayList;
public class ViewTrucksFragment extends Fragment {
TextView pageTitle;
MapView mMapView;
private GoogleMap googleMap;
public ViewTrucksFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) 是否可以为Android开发人员删除谷歌地图中不必要的标记和地点?我正在尝试显示一些地方,但是当用户放大地图中显示的一堆地方和标记时,这很正常,但我只想删除它们并仅显示我的标记。检查下图:
正如您在下图中所看到的,蓝色圆圈是我的图标,红色圆圈属于谷歌地图,我只想在应用程序中显示我的图标。
我正在尝试在Google Maps V2 API中获取地图中心的纬度和经度,并获取地图的宽度和长度.
这是我的旧代码(来自我开始修改的GMaps v1):
import com.google.android.gms.maps.GoogleMap;
private GoogleMap mGoogleMapView;
public LatLng getMapCenter()
{
if( mGoogleMapView != null )
{
return mGoogleMapView.getMapCenter();
}
/*if( mOpenStreetMapView != null )
{
return convertOSMGeoPoint( mOpenStreetMapView.getMapCenter() );
}*/
return null;
}
public int getHeight()
{
if( mGoogleMapView != null )
{
return mGoogleMapView.getHeight();
}
/*if( mOpenStreetMapView != null )
{
return mOpenStreetMapView.getHeight();
}*/
return 0;
}
public int getWidth()
{
if( mGoogleMapView != null )
{
return mGoogleMapView.getWidth();
}
/*else if( mOpenStreetMapView != …Run Code Online (Sandbox Code Playgroud) java android google-maps-api-2 google-maps-android-api-2 android-maps-v2
我试图使用SupportMapFragment,我收到此错误:
java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.c.c.o()' on a null object reference
at com.google.maps.api.android.lib6.c.z.b(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
错误出现在这里:
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
SupportMapFragment supportMapFragment;
if (Build.VERSION.SDK_INT < 21) {
supportMapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
} else {
supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
}
supportMapFragment.getMapAsync(this);
super.onViewCreated(view, savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
我实现了OnMapReadyCallBack:
public class MapsFragment extends SupportMapFragment implements OnMapReadyCallback {
Run Code Online (Sandbox Code Playgroud)
我没有抓住null引用的位置.
onCreate功能:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_maps, container, …Run Code Online (Sandbox Code Playgroud) 我正在使用此处提出的问题的代码自动完成textview google places api description - > place_id.我更改了代码以将其添加到我的应用程序中.当我运行代码时,它在我运行代码时给出了以下响应
07-28 11:17:19.244: E/result(350): {"error_message":"This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https:\/\/code.google.com\/apis\/console","predictions":[],"status":"REQUEST_DENIED"}
Run Code Online (Sandbox Code Playgroud)
我搜索了一些线程,并从下面的线程
我按照建议做了以下步骤.
Places API从控制台启用.Geocoding API从控制台启用.当我运行代码时,它仍然显示上面提到的错误.我是否需要从控制台启用任何其他API.
除此之外,地图工作得很好.如果您想知道这是我在清单中添加的api密钥.
<!-- Goolge Maps API Key Development mode -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAbo3luzbyQTuuPLOyo_Ml***********" />
Run Code Online (Sandbox Code Playgroud)
我正在直接添加服务器密钥以请求URL,如下所示
private ArrayList<String> autocomplete(String input) {
ArrayList<String> resultList = null;
HttpURLConnection conn …Run Code Online (Sandbox Code Playgroud) android autocompletetextview google-geocoding-api google-places-api google-maps-android-api-2
您好我正在使用Google Maps API v2在Android中显示地图.现在我想在卫星视图中显示Place标签.像SATUN,PERLIS等...虽然在正常的地图视图中显示.有人知道如何在卫星视图中实现这一目标吗?
我想在我的应用程序中实现google maps。我添加了一个Google Maps活动并创建了一个密钥。我没有在其他地方更改代码中的任何内容。我应该工作,但是不可以。
MapsActivity
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move …Run Code Online (Sandbox Code Playgroud)