34 lines
1.9 KiB
C#
34 lines
1.9 KiB
C#
using Assets.Scripts.Apis.Models;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Assets.Scripts.Apis
|
|
{
|
|
public class ThirdPartApi : ApiBase
|
|
{
|
|
public async Task<IpToGeoModel> GetLocationInfo()
|
|
{
|
|
return await GetThirdPartAsync<IpToGeoModel>("https://ip.seeip.org/geoip");
|
|
//return await GetThirdPartAsync<LocationModel>($"http://api.map.baidu.com/location/ip?ak=NsfCV0Sp5r0O8yY49RPIpOQZkWFlDnmi&coor=gcj02");
|
|
}
|
|
public async Task<Stream> GetMapImage(IpToGeoModel locationInfo)
|
|
{
|
|
return await GetThirdPartStreamAsync($"https://api.mapbox.com/styles/v1/juzetest/ckmkdjwsa1nvt17nr1ps4fqgs/static/{locationInfo.longitude.ToString(CultureInfo.InvariantCulture)},{locationInfo.latitude.ToString(CultureInfo.InvariantCulture)},12,0/1280x1280?access_token=pk.eyJ1IjoianV6ZXRlc3QiLCJhIjoiY2ttazhsbnpiMGVrdjJucGhyNnh6eXcxYSJ9.6zj2U9eFCNJRMljNlMxjVg");
|
|
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
|
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
|
}
|
|
public async Task<Stream> GetMapImage(double latitude,double longitude)
|
|
{
|
|
return await GetThirdPartStreamAsync($"https://api.mapbox.com/styles/v1/juzetest/ckmkdjwsa1nvt17nr1ps4fqgs/static/{longitude.ToString(CultureInfo.InvariantCulture)},{latitude.ToString(CultureInfo.InvariantCulture)},12,0/1280x1280?access_token=pk.eyJ1IjoianV6ZXRlc3QiLCJhIjoiY2ttazhsbnpiMGVrdjJucGhyNnh6eXcxYSJ9.6zj2U9eFCNJRMljNlMxjVg");
|
|
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
|
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
|
}
|
|
}
|
|
}
|