PokèmonGo如何使用Google Map API使用自定义Google地图?

KD.*_*KD. 22 android google-maps native google-api ios

我无法在Google API文档的任何位置找到其地图可以自定义(我知道它只能在网上自定义),但可以在PokèmonGo应用上看到它使用Google API来显示自定义地图.

PokèmonGo的参考使用谷歌地图:https://www.reddit.com/r/pokemongo/comments/4s71t1/suggestion_download_city_map_as_a_way_to_decrease/

任何人都能找到这种方法吗?

自定义地图我的意思是下面的地图,绿色和蓝天: 在此输入图像描述

ant*_*nio 45

我不知道PokémonGO是如何做到的,但你可以通过一些布局技巧获得非常好看的效果.我正在使用天空图像,我用渐变视图(模拟地平线)覆盖天空图像和地图,并使用半透明绿色视图覆盖地图.

activity_maps.xml

<LinearLayout
    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:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="170dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/sky"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="20dp"
            android:layout_alignParentBottom="true"
            android:background="@drawable/gradientsky"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="mypackage.MapsActivity"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#2200ff00"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="20dp"
            android:background="@drawable/gradientmap"/>

    </RelativeLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

gradientsky.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <gradient
        android:angle="90"
        android:startColor="#ffffff"
        android:endColor="#00ffffff" />
</shape>
Run Code Online (Sandbox Code Playgroud)

gradientmap.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <gradient
        android:angle="270"
        android:startColor="#ffffff"
        android:endColor="#00ffffff" />
</shape>
Run Code Online (Sandbox Code Playgroud)

MapsActivity.java(微不足道,但我添加它以便示例完整)

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_maps);
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap map) {
        map.getUiSettings().setCompassEnabled(false);
        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(39.87266,-4.028275))
                .zoom(18)
                .tilt(67.5f)
                .bearing(314)
                .build();
        map.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
}
Run Code Online (Sandbox Code Playgroud)

结果如下:

在此输入图像描述

另一种方法可能是使用TileOverlay来显示自定义地图.您可以在此处找到有关Tile Overlays的更多信息.

为了改进示例,您可能希望向天空添加一些视差效果,以便在地图旋转时移动.

  • 非常令人印象深刻 (3认同)

Bon*_*ide 5

维基百科对神奇宝贝Go的创造者说:

Niantic,Inc.是一家软件开发公司,以开发增强现实手机游戏Ingress和PokémonGo而闻名.它由Keyhole,Inc.创始人John Hanke于2010年成立,当时是谷歌的内部创业公司Niantic Labs .

如您所见,Niantic是Google的内部创业公司.尽管两家公司分道扬,,谷歌仍然投资于Niantic.所以我认为Niantic有一些可能性,我们无法使用.正如您所说,我在Android版Google地图文档中找不到任何方法.

我不确定这是否属实,这只是猜测.