Code Monkey home page Code Monkey logo

google-maps-utils's Introduction

google-maps-utils

Library of helpers for Google Maps on Android

Installation

Add the following dependency to your build.gradle file

	repositories {
		maven { url "https://jitpack.io" }
	}
	
	dependencies {
		compile 'com.github.jt-gilkeson:google-maps-utils:1.0'
	}

BlankInfoWindowAdapter

The BlankInfoWindowAdapter can be used to bring GoogleMap pins to the front (change z-index) when selected, without showing the info window above the pin.

How to use it

You can set the GoogleMap to use BlankInfoWindowAdapter as the InfoWindowAdapter. Once that is in place, you can simply call showInfoWindow on markers to bring them to the front.

// Set info window adapter for markers to the blank window adapter
mMap.setInfoWindowAdapter(new BlankInfoWindowAdapter(getLayoutInflater()));
		
...
		
// Select marker and bring to front
marker.showInfoWindow();

MapStateListener

The MapStateListener can be used to receive callbacks from GoogleMaps on Android, when the map settles or unsettles, is touched or released. Settling the maps means that the map has finished scrolling, zooming or animating in any way and is not currently being touched.

How to use it

You can use the MapStateListener by replacing your MapFragment with the included TouchableMapFragment, which allows for receiving touch events from the Map. With a reference to your TouchableMapFragment and the GoogleMap-object in your Activity, you can simply use the MapStateListener like this:

new MapStateListener(mMap, mMapFragment, this) 
{
  @Override
  public void onMapTouched() 
  {
    // Map touched
  }

  @Override
  public void onMapReleased() 
  {
    // Map released
  }

  @Override
  public void onMapUnsettled() 
  {
    // Map unsettled
  }

  @Override
  public void onMapSettled() 
  {
    // Map settled
  }
};

MarkerSelectionAnimator

MarkerSelectionAnimator demonstrates how to animate a marker when it is selected despite there being no animation support in the Marker class.

How to use it

You can use the MarkerSelectionAnimator by setting your GoogleMap MarkerClickListener to the one returned by getAnimatedMarkerClickListener(). After that your custom animation will run each time you click on a Marker. This class is meant to demonstrate how to do animation, you can easily override any of the methods in the class to do more customized animation.

MarkerSelectionAnimator mMarkerAnimator = new MarkerSelectionAnimator()
{
	@Override
	public void performAnimation(Marker marker, float t)
	{
	  // Do something with your marker based on the interpolated t value
	  // i.e. marker.setIcon, marker.setAlpha, marker.setPosition, etc.
	}

	@Override
	public void animationFinished(Marker marker)
	{
	  // Set the marker to the finished state
	}
};

mMap.setOnMarkerClickListener(mMarkerAnimator.getAnimatedMarkerClickListener())

google-maps-utils's People

Contributors

jt-gilkeson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.