如何在Android中制作小网址的长网址?

时间:2018-06-04 10:48:04

标签: java

我的问题是关于如何在android中缩短网址?

我想缩短的网址:

https://maps.googleapis.com/maps/api/staticmap?size=600x550&zoom=18&path=color:0x000000%7Cweight:4%7Cfillcolor:0xccffdd%7C13.050400679759749,80.25191437189446%7C13.05035618031911,80.25190825185891%7C13.050312498393671,80.25189760208146%7C13.050270070438803,80.25188252897114%7C13.050229320380598,80.2518631831335%7C13.05019065538017,80.25183975786574%7C13.050154461765421,80.25181248722541%7C13.050121101170989,80.25178164369173%7C13.0500909069249,80.25174753544309%7C13.050064180718087,80.25171050327782%7C13.050041189589969,80.2516709172091%7C13.050022163260302,80.25162917276784%7C13.050007291833879,80.25158568705068%7C13.049996723901078,80.25154089455253%7C13.049990565053191,80.25149524282527%7C13.049988876827392,80.25144918800581%7C13.04999167609187,80.25140319025871%7C13.049998934877307,80.25135770917827%7C13.050010580656313,80.25131319919636%7C13.050026497068114,80.25127010504208%7C13.050046525081186,80.2512288572979%7C13.050070464582243,80.25118986809771%7C13.050098076375702,80.25115352700865%7C13.05012908457365,80.25112019713892%7C13.050163179352428,80.25109021150953%7C13.050200020048273,80.25106386972699%7C13.050239238561126,80.25104143498969%7C13.050280443032577,80.25102313145808%7C13.050323221761163,80.25100914201504%7C13.050367147315972,80.25099960643843%7C13.05041178080738,80.25099462000458%7C13.050456676272294,80.25099423253629%7C13.050501385130065,80.25099844790503%7C13.050545460664575,80.25100722399222%7C13.05058846248764,80.2510204731101%7C13.050629960939268,80.25103806287785%7C13.050669541380644,80.25105981754434%7C13.050706808337083,80.25108551974415%7C13.050741389449474,80.25111491266937%7C13.050772939194772,80.25114770263559%7C13.05080114233835,80.25118356201635%7C13.050825717083727,80.25122213251653%7C13.050846417888163,80.25126302875249%7C13.050863037916065,80.2513058421025%7C13.05087541110561,80.25135014478977%7C13.050883413827977,80.25139549415647%7C13.050886966122606,80.25144143708673%7C13.05088603249615,80.25148751453395%7C13.05088062227709,80.25153326610754%7C13.050870789522547,80.25157823467289%7C13.05085663247816,80.25162197091895%7C13.050838292596431,80.25166403784762%7C13.050815953123397,80.25170401514005%7C13.05078983726769,80.25174150335633%7C13.050760205970304,80.25177612792663%7C13.050727355297372,80.25180754289366%7C13.050691613481955,80.25183543436947%7C13.050653337644462,80.25185952367165%7C13.050612910224405,80.25187957010786%7C13.050570735159203,80.25189537338072%7C13.05052723384817,80.25190677558916%7C13.05048284094202,80.25191366280609%7C13.050438,80.2519159662167|13.050400679759749,80.25191437189446

1 个答案:

答案 0 :(得分:2)

感谢您的支持,最后我得到了我需要的东西,

我使用了所有lat和long编码,

      /**
 * Encodes a sequence of LatLngs into an encoded path string.
 */
public String encode(final List<LatLng> path) {
    long lastLat = 0;
    long lastLng = 0;

    final StringBuffer result = new StringBuffer();

    for (final LatLng point : path) {
        long lat = Math.round(point.latitude * 1e5);
        long lng = Math.round(point.longitude * 1e5);

        long dLat = lat - lastLat;
        long dLng = lng - lastLng;

        encode(dLat, result);
        encode(dLng, result);

        lastLat = lat;
        lastLng = lng;
    }
    return result.toString();
}

private void encode(long v, StringBuffer result) {
    v = v < 0 ? ~(v << 1) : v << 1;
    while (v >= 0x20) {
        result.append(Character.toChars((int) ((0x20 | (v & 0x1f)) + 63)));
        v >>= 5;
    }
    result.append(Character.toChars((int) (v + 63)));
}

然后,我使用Google API再次编码完整的网址。