All Projects → KevinLiaoDev → CLocation

KevinLiaoDev / CLocation

Licence: other
中国国行安卓手机使用Google定位服务解决方案

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to CLocation

XamarinForms.LocationService
Xamarin Background Services, Background Location Updates, Location Updates, BroadCastReceiver
Stars: ✭ 61 (+84.85%)
Mutual labels:  location-services
pinpoint
🌎 A python script for finding your Mac.
Stars: ✭ 56 (+69.7%)
Mutual labels:  location-services
osx-location
🌎 Utility for polling OS X Location Services for current geographic coordinates. Works on Lion or better.
Stars: ✭ 31 (-6.06%)
Mutual labels:  location-services
SimpleLocationGetter
No description or website provided.
Stars: ✭ 21 (-36.36%)
Mutual labels:  location-services
AnywhereMock
kotlin语言,模拟定位 Simulated positioning
Stars: ✭ 24 (-27.27%)
Mutual labels:  location-services
AdvantEDGE
AdvantEDGE, Mobile Edge Emulation Platform
Stars: ✭ 36 (+9.09%)
Mutual labels:  location-services
Cartodb
Location Intelligence & Data Visualization tool
Stars: ✭ 2,537 (+7587.88%)
Mutual labels:  location-services
uv-index
This is a work-in-progress (🔧️) ultraviolet index viewer app for demonstrating Instant Apps + Kotlin + Dagger + MVP
Stars: ✭ 64 (+93.94%)
Mutual labels:  google-location-api
android
Where you can find everything Android from Mapzen
Stars: ✭ 106 (+221.21%)
Mutual labels:  location-services
ScoutAR
Augmented reality app displays nearby restaurant information in a live camera and map view.
Stars: ✭ 28 (-15.15%)
Mutual labels:  location-services
My Android Garage
A quick reference guide for Android development.
Stars: ✭ 66 (+100%)
Mutual labels:  location-services
locus-android
An Awesome Kotlin Location library to retrieve location merely in 3 lines of code
Stars: ✭ 280 (+748.48%)
Mutual labels:  android-location
surger
⚡ Is there surge pricing around me right now?
Stars: ✭ 20 (-39.39%)
Mutual labels:  location-services
gps-permission-checks-livedata
Sample project to demonstrate how GPS and Runtime Location Permission checks can be done on UI and Background Service using LiveData
Stars: ✭ 37 (+12.12%)
Mutual labels:  location-services
tracking-location-provider-android
Tracking the android mobile and animating marker smoothly in Google Maps. Tracking has been done both in foreground and background. Tested in Android Oreo 8.1, Android 6.0 and Android 5.0
Stars: ✭ 37 (+12.12%)
Mutual labels:  location-services
geoslack
📍 Geolocate your team in Slack
Stars: ✭ 18 (-45.45%)
Mutual labels:  location-services
location-api-sl
This API can be use to all developers to get location details of Sri Lanka 🇱🇰 including major cities, sub areas, districts and Provinces. ⛳️
Stars: ✭ 35 (+6.06%)
Mutual labels:  location-services
aws-serverless-fullstack-swift-apple-carplay-example
This application demonstrates a full-stack Apple CarPlay app that uses Swift for both the UI and the backend services in AWS. The app accesses Lambda functions written in Swift and deployed from Docker images. The app accesses Amazon Location Service and a 3rd party weather api to display information in the vicinity of the user.
Stars: ✭ 84 (+154.55%)
Mutual labels:  location-services
bdapis
Rest API service. Build with NodeJS, Express, MongoDB
Stars: ✭ 65 (+96.97%)
Mutual labels:  location-services
aic-mobile-ios
Art Institute of Chicago Official Mobile App
Stars: ✭ 29 (-12.12%)
Mutual labels:  location-services

CLocation-中国国行安卓手机使用Google定位服务解决方案

License

  • 国行安卓手机Google地图服务解决方案---CMaps

简介

  • 相信很多Android开发人员都有这样的痛点,当国内Android用户在国外要使用地图时,好像十分尴尬,没有非常成熟的地图解决方案。
  • 由于众所周知的原因,谷歌的很多优秀服务在国内无法使用,其中国行手机由于阉割无法使用谷歌地图服务是一个非常让人头痛的问题。主要问题有:
    • 一方面,国内地图服务提供商(百度地图、高德地图、腾讯地图)在境外的地图资源少得可怜。
    • 另一方面,国行安卓手机由于系统缺少谷歌三大件,使得国行手机使用谷歌地图服务几乎变得不可能。
  • 本项目是为了解决地图定位建立,围绕Google给出的API接口资源,通过一系列技术方案,使得国行手机在没有谷歌三大件的情况下也可以使用谷歌的地图服务。主要特征有:
    • 包含WIFI信号、基站和GPS的多重定位方案,具有定位误差小、适用性广、低消耗、速度快等特点。
    • 基于谷歌数据的定位,在国外实地测试定位准确率要明显高于国内定位服务。
    • 封装后的库体积小、逻辑清晰、使用简单,项目内还有多种相关实用工具可供使用。

使用前准备

需要的权限

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

获取Google Location API KEY

<meta-data
    android:name="GOOGLE_LOCATION_API_KEY"
    android:value="YOUR_API_KEY" />

使用过程

切换定位域名(非必须)

GetLocation.getInstance().setNetworkLocationUrl("https://googleapis.xxxxxx.com/");
  • 虽然该方案最主要的目标用户是在境外的国行手机,那么访问谷歌接口理应没有太大问题,但是不排除调试或者部分人需要在国内使用,特意封装了修改定位域名的方法。

使用多重定位(需访问谷歌服务器,境内网络需翻墙)

GetLocation.getInstance().setMultiLocationListener(new GetLocation.OnMultiLocationListener() {
    @Override
    public void onMultiLocation(double multilatitude, double multilongitude, long multiupdateTime, float multiaccuracy, float multibearing) {
        Double latitude, longitude;
        MyLocation myLocation = new MyLocation(multilatitude, multilongitude);
        //由于坐标系差异,中国大陆坐标需要转换
        if(BoundaryCheck.getInstance().IsInsideChina(myLocation)) {
            Point point = CoordinateConversion.wgs_gcj_encrypts(multilatitude, multilongitude);
            latitude = point.getLat();
            longitude = point.getLng();
        }else {
            latitude = multilatitude;
            longitude = multilongitude;
        }
        //注意:google网络定位坐标系为WGS84
        //经度:longitude,纬度:latitude,精度:multiaccuracy,方位:multiaccuracy,更新时间:multiupdateTime
    }

    @Override
    public void onFailed(int errorCode, String msg) {

    }
});
GetLocation.getInstance().startMultiLocation(getApplication(), this, false);

使用网络定位(需访问谷歌服务器,境内网络需翻墙)

GetLocation.getInstance().setNetworkLocationListener(new GetLocation.OnNetworkLocationListener() {
    @Override
    public void onNetworkLocation(double latitude, double longitude, long updateTime, float accuracy) {
        Double lat, lon;
        MyLocation myLocation = new MyLocation(latitude, longitude);
        //由于坐标系差异,中国大陆坐标需要转换
        if(BoundaryCheck.getInstance().IsInsideChina(myLocation)) {
            Point point = CoordinateConversion.wgs_gcj_encrypts(latitude, longitude);
            lat = point.getLat();
            lon = point.getLng();
        }else {
            lat = latitude;
            lon = longitude;
        }
        //注意:google网络定位坐标系为WGS84
        //经度:longitude,纬度:latitude,精度:accuracy,更新时间:updateTime
    }

    @Override
    public void onFailed(int errorCode, String msg) {
        
    }
});
GetLocation.getInstance().startNetworkLocation(getApplication());

使用GPS定位(需要在室外能搜索到GPS信号的地方使用)

GetLocation.getInstance().setGPSLocationListener(new GetLocation.OnGPSLocationListener() {
    @Override
    public void onGPSLocation(double latitude, double longitude, long updateTime, float accuracy, float bearing) {
        Double lat, lon;
        MyLocation myLocation = new MyLocation(latitude, longitude);
        //由于坐标系差异,中国大陆坐标需要转换
        if(BoundaryCheck.getInstance().IsInsideChina(myLocation)) {
            Point point = CoordinateConversion.wgs_gcj_encrypts(latitude, longitude);
            lat = point.getLat();
            lon = point.getLng();
        }else {
            lat = latitude;
            lon = longitude;
        }
        //经度:longitude,纬度:latitude,精度:accuracy,方位:accuracy,更新时间:updateTime
    }

    @Override
    public void onFailed(int errorCode, String msg) {
        
    }
});
GetLocation.getInstance().startGPSLocation(getApplication(),this);

释放资源

无论哪种的定位方式,在activity生命周期stop中一定要释放资源并且停止定位,以防资源浪费和异常奔溃

@Override
protected void onStop() {
    super.onStop();
    GetLocation.getInstance().onStop();
}

关于

  • 有任何建议或者使用中遇到问题都可以给我发邮件
  • Email:[email protected]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].