Third party high-German open platform high-German map positioning

Source: Internet
Author: User

Guide Jar Bag

Amap_location_v3.6.1_20171012.jar
Android_map3d_sdk_v5.4.0_20170928.jar
then put five programs into the Main method
arm64-v8a
Armeabi
armeabi-v7a
x86
x86_64

Two dependencies

Compile files (' Libs/android_map3d_sdk_v5.4.0_20170928.jar ')
    compile files (' libs/amap_location_v3.6.1_ 20171012.jar ')

Add Permissions in Androidmanifest.xml

<!--for network positioning--> <uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION" ></ Uses-permission> <!--used to access GPS--> <uses-permission android:name= "Android.permission.ACCESS_FINE_LOCAT ION "></uses-permission> <!--get carrier information to support provider information related to interface--> <uses-permission android:name=" Android. Permission. Access_network_state "></uses-permission> <!--to access WiFi network information, WiFi information will be used for network positioning--> <uses-permission A Ndroid:name= "Android.permission.ACCESS_WIFI_STATE" ></uses-permission> <!--this permission is used to obtain WIFI access. WIFI information is used for network positioning--> <uses-permission android:name= "Android.permission.CHANGE_WIFI_STATE" ></ Uses-permission> <!--used to access the network, network positioning needs to surf the internet--> <uses-permission android:name= "Android.permission.INTERNET" &G T;</uses-permission> <!--used to read the current status of the phone--> <uses-permission android:name= "Android.permission.READ_PHO Ne_state "></uses-permission> <!--write extended storage to extendCard writes data to write cache location data--> <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE" ></ Uses-permission> <!--used to request A-gps module--> <uses-permission android:name= "Android.permission.ACCESS_LOCATI On_extra_commands "></uses-permission> <!--used to obtain Bluetooth information for indoor positioning--> <uses-permission android:name=" an Droid.permission.BLUETOOTH "></uses-permission> <uses-permission android:name=" Android.permission.BLUETOOTH_ADMIN "></uses-permission> <!--Map SDK (including its search function) requires Basic permissions--> <!--allow programs to hit
    Open Network socket--> <uses-permission android:name= "Android.permission.INTERNET"/> <!--allow programs to set write permissions for built-in SD cards--> <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> <!--allows programs to get network status--> <us Es-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/> <!--allow programs to access WiFi network information--> &LT;USES-PE Rmission android:name= "Android.permission.ACCESS_WIFI_STATE"/&GT <!--allows programs to read and write mobile status and identity--> <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/> <!--allowed Sequential access to cellid or WiFi hotspots to get a rough location--> <uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/>

Add in Application

<meta-data android:name= "Com.amap.api.v2.apikey" 
    //Developer application
    keyandroid:value= " 3cc6884c3b4761c2682da91a295cb0d7 ">
        </meta-data>

        <service android:name=" Com.amap.api.location.APSService "></service>

Layout file

<com.amap.api.maps.mapview

        android:id= "@+id/map"

        android:layout_width= "Match_parent"

        android: layout_height= "Match_parent"/>

Last Main method code

Import Android.os.PersistableBundle;
Import android.support.v7.app.AppCompatActivity;
Import Android.os.Bundle;
Import Android.util.Log;

Import Android.widget.Toast;
Import com.amap.api.location.AMapLocation;
Import com.amap.api.location.AMapLocationClient;
Import com.amap.api.location.AMapLocationClientOption;
Import Com.amap.api.location.AMapLocationListener;
Import Com.amap.api.maps.AMap;
Import Com.amap.api.maps.MapView;

Import Com.amap.api.maps.model.MyLocationStyle;
    public class Mainactivity extends appcompatactivity {Mapview mmapview;
    Declares the Amaplocationclient class object public amaplocationclient mlocationclient;

    Declares Amaplocationclientoption object public amaplocationclientoption mlocationoption; Claim Locator callback listener public amaplocationlistener Mlocationlistener = new Amaplocationlistener () {@Override Pub LIC void onlocationchanged (Amaplocation amaplocation) {if (amaplocation!= null) {if (Amaplo Cation.geterrorcode () = = 0) {//You can parse amaplocation to get the appropriate content.
                    else {toast.maketext (mainactivity.this, "Asdfkskdjfnsik", Toast.length_long). Show ();
                    When the location fails, the Errcode (error code) information can be used to determine the cause of the failure, Errinfo is the error message, as detailed in the Error code table.
                            LOG.E ("Amaperror", "Location Error, Errcode:" + amaplocation.geterrorcode () + ", Errinfo:"
                + Amaplocation.geterrorinfo ());
    }
            }
        }
    };
    Private AMap AMap;
        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);

        Setcontentview (R.layout.activity_main);
        Mmapview = (Mapview) Findviewbyid (R.ID.MAP);
        Executes Mmapview.oncreate (savedinstancestate) When the activity executes onCreate, creating a map mmapview.oncreate (savedinstancestate);
        AMap = Mmapview.getmap ();
    Getloation ();
        private void Getloation () {Mylocationstyle mylocationstyle; Mylocationstyle = NEW Mylocationstyle ()//Initialize position Blue Point style class Mylocationstyle.mylocationtype (mylocationstyle.location_type_location_rotate); /continuous positioning, and moving the point of view to the center of the map, positioning points in accordance with the device direction rotation, and will follow the device movement.
        (1 seconds, 1 times) If you do not set Mylocationtype, this mode is also performed by default. Mylocationstyle.interval (2000); Set the positioning interval in the continuous positioning mode, only in the continuous positioning mode, the single position mode does not take effect.
        The unit is in milliseconds. Amap.setmylocationstyle (Mylocationstyle);/Set the style//amap.getuisettings () to locate the Blue point. Setmylocationbuttonenabled (True)
        ; Sets whether the default positioning button is displayed, not required.
        Amap.setmylocationenabled (TRUE);//set to True to start the display positioning Blue point, false indicates that the hidden location Blue point is not positioned, the default is False.
        Mylocationstyle.showmylocation (TRUE);//setting whether to display positioned little blue dots for scenarios where you want to use positioning only, do not want to use positioned little blue dots, and set false the concept of locating a blue dot no longer exists on the surface, but will continue to recall location information


        Mylocationstyle.anchor (0.0f,1.0f);//sets the anchor point method for locating the blue dot icon.
        Initialize location mlocationclient = new Amaplocationclient (Getapplicationcontext ());
        Set positioning callback Monitor Mlocationclient.setlocationlistener (Mlocationlistener);
        Initializes the Amaplocationclientoption object mlocationoption = new Amaplocationclientoption (); Set positioning mode to Amaplocationmode.highT_accuracy, high precision mode.
        Mlocationoption.setlocationmode (AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        Gets the location result once://the method defaults to False.

        Mlocationoption.setoncelocation (TRUE); Gets the most accurate once positioning result in the last 3s://Set Setoncelocationlatest (Boolean B) interface to TRUE, the SDK returns the highest precision positioning result in the most recent 3s when the location is started.
        If you set it to True,setoncelocation (Boolean B) The interface will also be set to true, otherwise not, default to False.
        Mlocationoption.setoncelocationlatest (TRUE);
        Set the location interval, in milliseconds, the default is 2000ms, the minimum 1000ms.
        Mlocationoption.setinterval (1000);
        Sets whether to return address information (default return address information) mlocationoption.setneedaddress (TRUE);
        Sets whether the impersonation location is allowed, the default is true, and the impersonation location Mlocationoption.setmockenable (true) is allowed;
        The unit is milliseconds, the default is 30000 milliseconds, and the recommended timeout should not be less than 8000 milliseconds.
        Mlocationoption.sethttptimeout (10000);
        Turn off caching mechanism mlocationoption.setlocationcacheenable (true);
        Setting the positioning parameter Mlocationclient.setlocationoption (mlocationoption) to the locating client object;
    Start positioning mlocationclient.startlocation (); } @Override protected void OnDestroy () {Super.ondestroy ();
    Mmapview.ondestroy ();
        } @Override protected void Onresume () {super.onresume ();
    Mmapview.onresume ();
        } @Override protected void OnPause () {super.onpause ();
    Mmapview.onpause (); @Override public void Onsaveinstancestate (Bundle outstate, Persistablebundle outpersistentstate) {Supe
        R.onsaveinstancestate (Outstate, outpersistentstate);
    Mmapview.onsaveinstancestate (outstate);
 }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.