如何使用GDK卡上显示静态地图?如何使用、静态、卡上、地图

2023-09-05 08:41:39 作者:19.假装快乐

在镜子API,我们可以使用这样的:

In Mirror API we can use something like:

<img src="glass://map?w=240&h=360&marker=0;42.369590,
      -71.107132&marker=1;42.36254,-71.08726&polyline=;42.36254,
      -71.08726,42.36297,-71.09364,42.36579,-71.09208,42.3697,
      -71.102,42.37105,-71.10104,42.37067,-71.1001,42.36561,
      -71.10406,42.36838,-71.10878,42.36968,-71.10703"
      height="360" width="240">

和它呈现漂亮的玻璃优化的地图卡。

And it renders nice Glass-optimized map on card.

如何使用GDK做同样的事情在活动?

How to do the same thing in Activity using GDK?

推荐答案

我结束了写这个方法,它会显示用户的当前位置,蓝点和地点位置,红点:

I ended up writing this method which displays user's current location as blue dot and venue location as red dot:

public static String getMapUrl(double latitude, double longitude, double currentLat, double currentLon, int width, int height) {
        try {
            String raw = "https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=" + width + "x" + height +
                "&style=feature:all|element:all|saturation:-100|lightness:-25|gamma:0.5|visibility:simplified" +
                "&style=feature:roads|element:geometry&style=feature:landscape|element:geometry|lightness:-25" +
                "&markers=icon:" + URLEncoder.encode("https://m.xsw88.com/allimgs/daicuo/20230905/1856.png",
                "UTF-8") + "|shadow:false|" + currentLat + "," + "" + currentLon+"&markers=color:0xF7594A|" + latitude + "," + longitude;
            return raw.replace("|", "%7C");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }

这看起来是这样的:

It looks like this:

 
精彩推荐
图片推荐