小编Mic*_*hel的帖子

我为V2创建了一个Android Map API密钥,无法显示地图

我为版本2创建了一个Google API密钥,并在清单中使用了该密钥,但我无法在设备上显示地图.

我已按照谷歌地图文档中提供的所有内容.我也用过这个链接.

MainActivity.java.

包com.example.googlenewmap;

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;

    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.SupportMapFragment;
    import com.google.android.gms.maps.model.BitmapDescriptorFactory;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.MarkerOptions;

    public class MainActivity extends FragmentActivity {
        static final LatLng HAMBURG = new LatLng(53.558, 9.927);
        static final LatLng KIEL = new LatLng(53.551, 9.993);
        private GoogleMap map;

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

            map = ((SupportMapFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.map)).getMap();

            if (map != null) {
                map.addMarker(new MarkerOptions().position(HAMBURG)
                        .title("Hamburg"));
                map.addMarker(new MarkerOptions()
                        .position(KIEL)
                        .title("Kiel")
                        .snippet("Kiel")
                        .icon(BitmapDescriptorFactory
                                .fromResource(R.drawable.ic_launcher)));
            }

        }

    }
Run Code Online (Sandbox Code Playgroud)

清单文件

 <?xml version="1.0" …
Run Code Online (Sandbox Code Playgroud)

android google-maps

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

标签 统计

android ×1

google-maps ×1