Android共享意图与谷歌地图位置和URL Shortener API [英] Android sharing intent with google maps location and URL Shortener API

查看:122
本文介绍了Android共享意图与谷歌地图位置和URL Shortener API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图分享经纬度为的位置;

  String uri =http:// maps。 google.com/maps?daddr=+ latLngMaps.latitude +,+ latLngMaps.longitude; 

使用以下代码行:

  Intent sharingIntent = new Intent(Intent.ACTION_SEND); 
sharingIntent.setType(text / plain);
String ShareSub = pharmacyName +\\\
+ pharmacyAddress;
sharingIntent.putExtra(Intent.EXTRA_TEXT,ShareSub +\\\
+ shortURL);
startActivity(Intent.createChooser(sharingIntent,Share With?));

我想要做的是:



我使用URL shortener api并将转换为http:// maps.google.com/maps?daddr=+ latLngMaps.latitude +,+ latLngMaps.longitude; 为goo.gl/xxxxx



它变成这样

当我在Whatsapp上共享我的地图时,是否有可能获得第一张图片的视图?



如果不是,我怎样才能将我的链接缩短为goo.gl/maps/xxxx而不是goo.gl/xxxx?
<您需要使用Google静态地图API,它将地图作为图像返回,您可以通过意图进行分享。您还可以自定义静态地图像你可以设置标记位置,设置缩放级别。

  Url 
https://maps.googleapis.com/maps/api/staticmap?center=Australia&size = 640x400&放大器;风格=元素:标签|可见性:关闭和放大器;风格=元素:geometry.stroke |可见性:关闭和放大器;风格=特征:景观|元素:几何|饱和度:-100安培;风格=特点:水|饱和度:-100 | invert_lightness:true& key = YOUR_API_KEY

您也可以使用谷歌地图的较轻版本选项。它也显示为图像。这可以点击,也有谷歌地图定制。



访问我的网站学习Kotlin和Android - Developine


I am trying to share a location with latitude and longitude as;

String uri = "http://maps.google.com/maps?daddr=" + latLngMaps.latitude + "," + latLngMaps.longitude;

Using these lines of code:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                String ShareSub = pharmacyName + "\n" + pharmacyAddress;
                sharingIntent.putExtra(Intent.EXTRA_TEXT, ShareSub + "\n" + shortURL);
                startActivity(Intent.createChooser(sharingIntent, "Share With?"));

What I want to do is:

I am using URL shortener api and converting the "http://maps.google.com/maps?daddr=" + latLngMaps.latitude + "," + latLngMaps.longitude; to goo.gl/xxxxx

It becomes like this

Is it possible to get that first Image's view when I share my map on Whatsapp?

If it is not, How can I shorten my link as goo.gl/maps/xxxx not goo.gl/xxxx ?

解决方案

You need to use Google static Maps API which returns a map as an Image which you can share through intent.You can also customize static maps API like you can set marker location, set zoom level.

Url
https://maps.googleapis.com/maps/api/staticmap?center=Australia&size=640x400&style=element:labels|visibility:off&style=element:geometry.stroke|visibility:off&style=feature:landscape|element:geometry|saturation:-100&style=feature:water|saturation:-100|invert_lightness:true&key=YOUR_API_KEY

You can also use the lighter version of google map using google map options. it is also displayed as an Image. which can be clicked and also has google map customization.

visit my website for learnning Kotlin and Android - Developine

这篇关于Android共享意图与谷歌地图位置和URL Shortener API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆