Code Monkey home page Code Monkey logo

ubee-maps-example's Introduction

Ubee Maps

For Android SDK 14+

  1. Register your App

Create your application [here] create_app (You will need to have an account to do that).

  1. Download SDK and Dependencies

Download the latest (Release v1.3.4-b) [Ubee Android SDK] library_project

Dependencies

  • Android Support Library v4 (Already included on the Ubee Android SDK)
  • Google Protocol Buffers v2.5.0 (Already included on the Ubee Android SDK)
  • Google Play Services SDK (Download [here] google_play_services_doc_install).
  1. Integrating SDK

Eclipse:

  1. Select File > Import.
  2. Select Existing Android Code Into Workspace and click Next.
  3. Browse to the ubee-android-sdk folder.
  4. Click Finish to import the project. You should now see a new project titled ubee-android-sdk.

You now have a library project for the Ubee SDK that you can use with one or more application projects.

Add the library to your application project:

  1. In the Project Explorer, right-click your project and select Properties.
  2. In the category panel on the left side of the dialog, select Android.
  3. In the Library pane, click the Add button.
  4. Select the ubee-android-sdk library project and click OK.
  5. In the properties window, click OK.

We use the Android Support Library v4, so if you use it in your project, it may cause conflict. You can just remove the one from your project, which is on your folder libs/android-support-v4.jar

AndroidManifest.xml

Add the following permissions to your manifest file:

<manifest>
    <!-- These permissions are mandatory to run Ubee SDK -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- This permissions is optional. It allow the SDK to write it's temporary data on the external storage instead of the application internal memory. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

Adding the following Service to your manifest file:

<application> 
     <service android:name="in.ubee.api.location.LocationService" 
        android:exported="false"/>
</application>
  1. Integrating Google Play Services SDK

Add the Google Play Services SDK to your application project.

<application> 
    [...]
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>

If you need some help, see the official [documentation] google_play_services_doc to integrate the Google Play Services SDK.

  1. Initializating SDK

You will need to use your application id (app_id) and secret (app_secret) that you received when you created your application [here] create_app. Just add the lines below in your first Activity onCreate method.

UbeeOptions options = UbeeOptions.getInstance(this);
options.setMapsKey(<Your_Maps_Key>,<Your_Maps_Secret>);
options.setLogEnabled(true);
Ubee.init(this, options);

Usage Indoor Location

  • Register/Unregister a context to receive the device current indoor location
private OnMapsLocationListener mLocationListener = new OnMapsLocationListener() {
    
	@Override
	public void onLocationChanged(Location location) {
	}
	
	@Override
	public void onError(LocationError locationError) {
	}
};

@Override
protected void onResume() {
    super.onResume();
    Ubee.registerLocationCallback(this, mLocationListener);
}

@Override
protected void onPause() {
    super.onPause();
    Ubee.unregisterLocationCallback(this, mLocationListener);
}

Request User Retails

Request the list of the retails authorized for the user application

JSONObject retailsAsJson = Ubee.requestRetails();
List<Retail> retails = Retail.parseListFromJSON(retailsAsJson);

Usage IndoorMapView

###Current Features:

  • Zoom
  • Translation
  • Fling
  • SVG Parser

###QuickStart:

  • Load a retail at the view
  • Receive the list of retail maps loaded for the selected retail on the method onRetailLoadFinished(Retail retail, List retailMaps)
  • Use one of the following methods switch floors (No map will be shown until any of the following methods are run)
public void setPreviousFloor();
public void setNextFloor();
public void setFloor(int floor);

###Example

public class MyClass extends Activity {
    private IndoorMapView mIndoorMapView;

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mIndoorMapView = new IndoorMapView(this);
        mIndoorMapView.setRetailById("your_retail_id", new OnMapViewLoadListener() {
        
            		@Override
		    		public void onRetailMapLoadFinished(RetailMap retailMap) {
                    }
				
			    	@Override
			    	public void onRetailLoadFinished(Retail retail, List<RetailMap> retailMaps) {
                        mIndoorMapView.setNextFloor();
			    	}
				
			    	@Override
			    	public void onLoadError(UbeeAPIException e) {
			    		e.printStackTrace();
			    	}
	        });
        this.setContentView(mIndoorMapView);
	}
}

####You can also validate if there is a floor to be shown on the next/previous methods.

public boolean hasNextFloor();
public boolean hasPreviousFloor();

###Loading the user position

public void setUserLocation(Location newLocationPoint);

####Usage Steps:

  • Create your IndoorMapView.
  • Create the OnMapsLocationListener
  • Pass the callback of OnLocationChanged(Location location) to the IndoorMapView.
  • Register the LocationCallback when you want to start tracking
  • Unregister the LocationCallback when you want to stop tracking

####Example

IndoorMapView mIndoorMapView = [...];
OnMapsLocationListener mLocationListener =  new OnMapsLocationListener() {

    @Override
    public void onLocationChanged(Location location) {
	    mIndoorMapView.setUserLocation(location);
    }

	@Override
		public void onError(LocationError locationError) {
	}
};
Ubee.registerLocationCallback(context, mLocationListener);
[...]
Ubee.unregisterLocationCallback(context, mLocationListener);

ubee-maps-example's People

Contributors

falconegabriel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.