【问题标题】:How does Pokèmon Go uses custom Google map using Google Map API?Pokèmon Go 如何使用 Google Map API 使用自定义 Google 地图?
【发布时间】:2016-07-12 08:33:19
【问题描述】:

我无法在 Google API 文档中找到可以自定义其地图的任何地方(我知道它只能在网络上自定义)但可以在 Pokèmon Go 上看到 strong> 应用程序,它使用 Google API 显示自定义地图。

Pokemon Go 参考使用谷歌地图:https://www.reddit.com/r/pokemongo/comments/4s71t1/suggestion_download_city_map_as_a_way_to_decrease/

任何人都能够弄清楚这种方法吗?

自定义地图 i 是指下面的绿色和蓝色天空的地图:

【问题讨论】:

标签: android ios google-maps google-api native


【解决方案1】:

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

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>

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>

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>

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));
    }
}

结果如下:

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

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

【讨论】:

  • 你成就了我的一天:D
  • 太棒了,你能用这个例子提交一个要点吗?
  • 太棒了!非常感谢!
【解决方案2】:

Wikipedia arcticle 致 Pokémon Go 的创造者:

Niantic, Inc. 是一家软件开发公司,以 开发增强现实手机游戏 Ingress 和 Pokémon Go。 它由 Keyhole, Inc. 创始人 John Hanke 于 2010 年成立,当时名为 Niantic Labs,Google 的内部初创公司。

如您所见,Niantic 是 Google 的一家内部创业公司。尽管两家公司分道扬镳,但谷歌仍然投资于 Niantic。所以我认为 Niantic 有一些可能性,我们无法获得。正如您所说,我在 Android 的 Google Maps 文档中都没有找到方法。

我不确定这是否属实,这只是一个猜测。

【讨论】:

    猜你喜欢
    • 2016-04-23
    • 2016-02-05
    • 1970-01-01
    • 1970-01-01
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多