国外经纬度计算GPS 计算 google地图计算 必应地图 和mapbox 地图

自从google 退出中国之后,很多的不方便.
地图勉强能用
网上有些api都是要收费的,而且收费比较多.
原来一直用必应地图提供的接口
这里写图片描述

GeocodeRequest geocodeRequest = new GeocodeRequest();

报错 the service method is not found
看了官方的列子也是这样的.
google地图没有http接口更新.网页的对请求限制100次/天

我们系统每天更新经纬度数据比较多,每天得更新好几万的数据.

下面是google地图计算经纬度接口js版本的,需要通过ajax 单条调用.

function GetGpsGoogle(address,obj) {
    $.ajax({
        type: "get",
        dataType: "json",
        async: false,
        url: "http://maps.google.cn/maps/api/geocode/json?address=" + address + "",
        success: function (data) {
            if (data.status == 'OK') {
                var lat = data.results[0].geometry.location.lat;
                var lng = data.results[0].geometry.location.lng;
                //更新业务数据
            }
        }
    });
}

必应地图的接口

   private void MakeGeocodeRequest()
        {
            string Results = "";
            try
            {
                //  Set a Bing Maps key before making a request 
                string key = "9hOiCZ9CeqcrrtLulix6~vW9_U20gmnMkdIBj-HwxGw~AuMx8W3CzxTLBhR6Evg9le2-p2sPZJcjZA1taqoQSjHjx1v2TXpdUyfE1pcA9sUP";
                GeocodeRequest geocodeRequest = new GeocodeRequest();
                //  Set the credentials using a valid Bing Maps Key 
                geocodeRequest.Credentials = new Credentials();
                geocodeRequest.Credentials.ApplicationId = key;
                //  Set the full address query 
                geocodeRequest.Query = "1 Microsoft Way, Redmond, WA";
                //  Set the options to only return high confidence results 
                ConfidenceFilter[] filters = new ConfidenceFilter[1];
                filters[0] = new ConfidenceFilter();
                filters[0].MinimumConfidence = Confidence.High;
                GeocodeOptions geocodeOptions = new GeocodeOptions();
                geocodeOptions.Filters = filters;
                geocodeRequest.Options = geocodeOptions;
                //  Make the geocode request 
                GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
                Results = geocodeResponse.Results[0].DisplayName;
            }
            catch (Exception ex)
            {
                Results = "An exception occurred: " + ex.Message;
            }
        }

现在报错,不知道谁有解决方案吗,这个接口一个秘钥能更新10万次.就是不能访问了.

最后有找了一个接口就是mapbox地图.
每分钟更新600次.这个量算好了.就是接口响应速度有点慢.

 string GetPost = string.Format("https://api.mapbox.com/geocoding/v5/mapbox.places/{0}.json?access_token='你的秘钥'", address);
                getStr = Command.HttpHelper.Get_Http(GetPost);
                VO.BoxMap.BoxMapGpsVO model = Command.JsonHelper.ParseFormJson<VO.BoxMap.BoxMapGpsVO>(getStr);
                if (model != null)
                { 
                    if (model.features != null && model.features.Length>0)
                    { 
                        latitude = model.features[0].center[0].ToString();
                        longitude = model.features[0].center[1].ToString();
                    }
                }

走的是httpget请求,得到结果最后反序列化,key就不公开了,需要的可以联系我,或者找到原文来源.

这是计算国外地图经纬度的几种方式,现在mapbox最好用,google地图最精准.

文章来源:http://www.zhruanjian.com/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值