Coder Social home page Coder Social logo

ubudu / googlemapslayout-android Goto Github PK

View Code? Open in Web Editor NEW
4.0 5.0 1.0 391 KB

Android library module that provides Google Maps layout UI component with an API designed for handling Indoor Location use cases

License: MIT License

Java 100.00%

googlemapslayout-android's Introduction

Ubudu Google Map Layout

Android library module that provides Google Map layout component with an API designed for handling Indoor Location use cases. API covers things like:

  • position marker placing + style (color, size, halo color and radius)
  • custom marker placing with tags for clean maintanance + style (color or bitmap, size)
  • zones highlighing + style(fill color, stroke color)
  • camera control (zoom, rotation, animate/not animate)
  • paths drawing

How to use

Installing

Add Ubudu nexus repository url to your build.gradle file:

repositories {
	maven { url 'http://nexus.ubudu.com:8081/nexus/content/groups/public/' }
	// ...
}

Then add the following dependency:

dependencies {
    compile('com.ubudu.gmaps:maplayout:1.2.1@aar')
    // ...
}

Integration

Important! MapLayout uses the Google Maps Android API. It is mandatory to register the app project on the Google API Console and get a Google API key which can be then added to the app. More information of how to achieve this can be found here.

Google Maps API key must be specified in the mobile app's manifest as a meta-data:

<meta-data
	android:name="com.google.android.maps.v2.API_KEY"
	android:value="AIzaSyC30GXjc8Mep_tPYglfzA0UXBM5UYdUmmU" />

The UI component to be placed in the layout xml file:

<com.ubudu.gmaps.MapLayout
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

To initialize the layout object in the mobile application's code call the following in your fragment's onViewCreated or in your onCreate of your activity:

mMapLayout.init(getContext());

To handle events coming from the map layout a listener interface has to be implemented:

mMapLayout.setEventListener(new MapLayout.EventListener() {

	@Override
	public void onMapReady() {
		// called when map layout is ready to handle API calls
	}
	
	@Override
	public void onZoneClicked(Zone zone, Polygon polygon) {
		Log.i(TAG,"Polygon clicked: "+zone.getName()+", polygon id: "+polygon.getId());
	}
	
	@Override
	public void onMarkerClicked(com.ubudu.gmaps.model.Marker marker, Marker googleMarker) {
		Log.i(TAG, "Marker clicked: " + marker.getTitle() + ", tag: " + marker.getTags());
	}
	
});

Sample API calls:

    // zone example
    ArrayList<LatLng> sampleZoneCoordinatesList = new ArrayList<>();
    sampleZoneCoordinatesList.add(new LatLng(52.200766, 21.024592));
    sampleZoneCoordinatesList.add(new LatLng(52.200872, 21.026395));
    sampleZoneCoordinatesList.add(new LatLng(52.201608, 21.027189));
    sampleZoneCoordinatesList.add(new LatLng(52.202134, 21.026052));
    sampleZoneCoordinatesList.add(new LatLng(52.201450, 21.024185));
    // normal and highlighted map layout's zone options will be used for appearance
    mMapLayout.addZone("sample zone 1",sampleZoneCoordinatesList);

.

    // sample custom marker
    mMapLayout.addMarker("test_markers", new LatLng(52.200682, 21.024481)
            , "test marker 2");

.

    // setup location marker options
    mMapLayout.setLocationMarkerOptionsStrategy(new MarkerOptionsStrategy()
            .setNormalMarkerOptions(MarkerOptionsFactory
                    .circleWithHaloMarkerOptions(15, "#4285F4", 100, "#304235F4")));

.

    // mark location
    mMapLayout.markLocation(new LatLng(52.201214, 21.025923));

.

    // update the camera
    mMapLayout.updateCamera(true);

More use examples can be found in the sample app's MapFragment class source.

googlemapslayout-android's People

Contributors

mgasztold avatar fkruta avatar

Stargazers

Omniyyah avatar Rico Ts avatar Pedro Francisco de Sousa Neto avatar chonamdoo avatar

Watchers

 avatar James Cloos avatar Thomas Saphir avatar  avatar  avatar

Forkers

jameschen00

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.