谷歌地图GroundOverlay显示

时间:2014-03-04 23:15:31

标签: android google-maps google-maps-api-2

我正试图在谷歌地图上使用地面覆盖,看看我是否可以在谷歌地图上获取图像。我没有错误,并查看文档和示例。图像不显示。 以下是我实现地面覆盖的代码的一部分:

private GroundOverlay mGroundOverlay;

private static final LatLng NEWARK = new LatLng(40.714086, -74.228697);
.....

protected void onCreate(Bundle savedInstanceState) {
.....

public void setImage(){
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11));

    mGroundOverlay = googleMap.addGroundOverlay(new GroundOverlayOptions()
    .image(BitmapDescriptorFactory.fromResource(R.drawable.battery)).anchor(0, 1)
    .position(NEWARK , 85000f,6500f));
}

我有图像" battery.jpeg"在我的资源文件夹中,drawable-hpdi

有人可以查看我的代码并告诉我我错过了什么吗?由于我是Android的初学者,我也想要一个解释。

2 个答案:

答案 0 :(得分:0)

也许我错误地阅读了您的意图,但如果您尝试使用Android Maps API,则必须从API信息中心获取密钥;不可替代的vogella有一个教程:

http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html

如果你是一个新的机器人,我可以想到没有更好的程序员可以学习。

另外,你可以发布你的logcat吗?仅供参考:您可以在root设备上使用Logcat Extreme来获取覆盖在您的设备上的实时日志记录,您也可以将其发送到文件...这是蜜蜂的膝盖并倾注日志读数会大大加速您的教育。 =]

gl hf

答案 1 :(得分:0)

检查一下

         LatLng c1 = new LatLng( -33.67032801,151.30209310);
         LatLng c2 = new LatLng( -33.66687426,151.30269820);
         LatLng c3 = new LatLng( -33.66657936,151.30026840);
         LatLng c4 = new LatLng( -33.67003309,151.29966320);
         LatLngBounds latLngBounds = new LatLngBounds(c1, c3).including(c2).including(c4);
         GroundOverlayOptions groundOverlayOptions = new 
                                                   GroundOverlayOptions();
        BitmapDescriptor bitmapDescriptor = 
                   BitmapDescriptorFactory.fromAsset("h1.png");
    groundOverlayOptions.image(bitmapDescriptor);
    groundOverlayOptions.positionFromBounds(latLngBounds);
    map.addGroundOverlay(groundOverlayOptions);
相关问题