Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android Studio谷歌地图自定义地图,只想显示自定义地图,但利用谷歌地图的功能_Java_Android_Google Maps_Google Maps Android Api 2_Google Maps Api 2 - Fatal编程技术网

Java Android Studio谷歌地图自定义地图,只想显示自定义地图,但利用谷歌地图的功能

Java Android Studio谷歌地图自定义地图,只想显示自定义地图,但利用谷歌地图的功能,java,android,google-maps,google-maps-android-api-2,google-maps-api-2,Java,Android,Google Maps,Google Maps Android Api 2,Google Maps Api 2,我知道标题可能会有点混乱,我会尽力在这里解释。我正在尝试为一个慈善机构创建一个应用程序,他们希望为他们的网站创建一个地图,以便他们可以浏览。我目前正在使用谷歌地图覆盖功能。我几乎得到了想要的结果,但有几件事我想不通 @Override public void onMapReady(GoogleMap googleMap) { //LatLng NEWARK = new LatLng(51.251115, -0.599319); LatLngBounds Newa

我知道标题可能会有点混乱,我会尽力在这里解释。我正在尝试为一个慈善机构创建一个应用程序,他们希望为他们的网站创建一个地图,以便他们可以浏览。我目前正在使用谷歌地图覆盖功能。我几乎得到了想要的结果,但有几件事我想不通

    @Override
    public void onMapReady(GoogleMap googleMap) {
    //LatLng NEWARK = new LatLng(51.251115, -0.599319);

    LatLngBounds NewarkBounds = new LatLngBounds(
            new LatLng(50.807686, -0.430219),
            new LatLng(50.811414, -0.424310)

    );

    mMap = googleMap;
    mMap.getUiSettings().setMapToolbarEnabled(false);
    //mMap.addMarker(new MarkerOptions().position(NEWARK).title("Reserve"));


    LatLng myPosition = new LatLng(latitude,longitude);


    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.maptest))
            .positionFromBounds(NewarkBounds)
            .visible(false);


    if((myPosition.latitude <= PLACETEXT && myPosition.latitude >=PLACETEXT ) && 
    (myPosition.longitude >= -PLACETEXT && myPosition.longitude <= -PLACETEXT )){
        newarkMap.visible(true);
        mMap.setMyLocationEnabled(true);

    }
    else {
        mMap.setMyLocationEnabled(false);
    }

    GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);


    mMap.setMyLocationEnabled(true);
    mMap.setOnMyLocationButtonClickListener(this);
    mMap.setOnMyLocationClickListener(this);


    mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(myPosition.latitude, 
    myPosition.longitude)));
    mMap.setMapType(0);
    mMap.setLatLngBoundsForCameraTarget(NewarkBounds);
}
@覆盖
4月1日公开作废(谷歌地图谷歌地图){
//LatLng NEWARK=新LatLng(51.251115,-0.599319);
LatLngBounds NewarkBounds=新LatLngBounds(
新车床(50.807686,-0.430219),
新车床(50.811414,-0.424310)
);
mMap=谷歌地图;
mMap.getUiSettings().setMapToolbarEnabled(false);
//mMap.addMarker(newmarkeroptions().position(NEWARK.title)(“Reserve”);
LatLng myPosition=新LatLng(纬度、经度);
GroundOverlayOptions newarkMap=新的GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.maptest))
.positionFromBounds(NewarkBounds)
.可见(假);
如果((myPosition.latitude=PLACETEXT)&&

(myPosition.longitude>=-PLACETEXT&&myPosition.longitude这是可能的。请查看Google在上的文档

将相机设置为边界内最大可能缩放级别的代码片段:

private GoogleMap mMap;
// Create a LatLngBounds that includes Australia.
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

// Set the camera to the greatest possible zoom level that includes the bounds
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(AUSTRALIA, 0));
private GoogleMap mMap;
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(AUSTRALIA.getCenter(), 10));
private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
  new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);
在边界内使相机居中:

private GoogleMap mMap;
// Create a LatLngBounds that includes Australia.
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

// Set the camera to the greatest possible zoom level that includes the bounds
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(AUSTRALIA, 0));
private GoogleMap mMap;
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(AUSTRALIA.getCenter(), 10));
private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
  new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);
限制用户在范围内滚动和平移:

private GoogleMap mMap;
// Create a LatLngBounds that includes Australia.
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

// Set the camera to the greatest possible zoom level that includes the bounds
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(AUSTRALIA, 0));
private GoogleMap mMap;
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(AUSTRALIA.getCenter(), 10));
private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
  new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);

希望这有帮助!

我觉得这是不可能的?我想知道你是否可以用谷歌创建一个自定义地图,然后导入它,而不是谷歌地图预定义地图?嗨,埃文,很抱歉回复太晚。这非常有帮助!很高兴听到!)嗨,埃文,这解决了我的大部分问题,但仍然存在一个非常令人沮丧的问题,出于某种原因,地面覆盖层周围有一个灰色的填充物,我似乎无法修复。我可以修复它,但它会弄乱lat/lngs。这个项目似乎有同样的问题,但从来没有解决方案?”有什么想法吗?如果不清楚的话,我已经发了一篇新帖子。嘿!当然,我会调查一下,然后再给你回复:)