InteractiveInfoWindowAndroid


Source link: https://github.com/Appolica/InteractiveInfoWindowAndroid

InteractiveInfoWindowAndroid by Appolica

InteractiveInfoWindowAndroid is (suprisingly :D) an Android library which gives you the opportunity to show interactive info windows on your google map. The library is developed and maintained by Appolica. The UI of your window is encapsulated in your own fragment with its own lifecycle. You just pass it to the InfoWindowManager and display it above whichever marker you want.

How to use?

Add it to your Android project

repositories {

  jcenter() 
}
  dependencies {

  compile 'com.appolica:interactive-info-window:v1.0.6' 
}
 

And then use it in your code

First you need to add our map fragment to your layout. It embeds the SupportMapFragment and all the magic which makes this library to work and provides its API.

  <RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

 ...

 <fragment

 android:id="@+id/infoWindowMap"

 android:layout_width="match_parent"

 android:layout_height="match_parent"

 android:name="com.appolica.interactiveinfowindow.fragment.MapInfoWindowFragment"/>
 </RelativeLayout>

Then you obtain an instance of it and basically you are ready to go:

  final MapInfoWindowFragment mapInfoWindowFragment =

(MapInfoWindowFragment) getSupportFragmentManager().findFragmentById(R.id.infoWindowMap);

 final InfoWindow infoWindow = new InfoWindow(marker, markerSpec, fragment);

// Shows the InfoWindow or hides it if it is already opened.
mapInfoWindowFragment.infoWindowManager().toggle(infoWindow, true);
 

Listen when an InfoWindow is hiding or showing by implementing InfoWindowManager.WindowShowListener:

  infoWindowManager.setWindowShowListener(new InfoWindowManager.WindowShowListener() {

  @Override
  public void onWindowShowStarted(@NonNull InfoWindow infoWindow) {

  
}

@Override
  public void onWindowShown(@NonNull InfoWindow infoWindow) {

  
}

@Override
  public void onWindowHideStarted(@NonNull InfoWindow infoWindow) {

  
}

@Override
  public void onWindowHidden(@NonNull InfoWindow infoWindow) {

  
}

}
);

You can get an instance of the GoogleMap by calling mapInfoWindowFragment.getMapAsync(onMapReadyCallback).

If you don't want to use our fragment it's okay but it's not that straight-forward. You have to bind the InfoWindowManager to your Activity/Fragment and add TouchInterceptFrameLayout as a parent of your map. Take a look at this example.

API

MapInfoWindowFragment:

  • public void getMapAsync(OnMapReadyCallback onMapReadyCallback) - Use this method to get the GoogleMap object asynchronously from our fragment.
  • public InfoWindowManager infoWindowManager() - Get an instance of InfoWindowManager to control your InfoWindow.

InfoWindowManager:

  • public void toggle(@NonNull final InfoWindow infoWindow, final boolean animated) - Shows or hides the given InfoWindow with or without animation.
  • public void show(@NonNull final InfoWindow infoWindow, final boolean animated) - Shows the given InfoWindow with or without animation.
  • public void hide(@NonNull final InfoWindow infoWindow, final boolean animated) - Hides the given InfoWindow with or without animation.
  • public void setWindowShowListener(WindowShowListener windowShowListener) - Listen for InfoWindow show/hide events.
  • public void setShowAnimation(Animation showAnimation) - Set your own InfoWindow show animation.
  • public void setHideAnimation(Animation hideAnimation) - Set your own InfoWindow hide animation.
  • public void setContainerSpec(ContainerSpecification containerSpec) - Set the container specification for your InfoWindow container. The ContainerSpecification class wraps (at least for now) only the backgorund drawable of the container view. You can change the background from here.

InfoWindow:

  • public InfoWindow(Marker marker, MarkerSpecification markerSpec, Fragment fragment) -

    • marker - The marker which determines the window's position on the screen
    • markerSpec - Provides the marker's offsetX and offsetY
    • fragment - The actual window that is displayed on the screen
  • public InfoWindow(LatLng position, MarkerSpecification markerSpec, Fragment fragment) -

    • position - The LatLng position which determines the window's position on the screen.
    • markerSpec - Provides the marker's offsetX and offsetY
    • fragment - The actual window that is displayed on the screen

InfoWindow.MarkerSpecification:

  • public MarkerSpecification(int offsetX, int offsetY) - Create marker specification by providing InfoWindow's x and y offsets from marker's screen location.

    Note: By default offsetX will be ignored, so in order for it to take effect, you must call setCenterByX(false).

    Also if you want to use dp, you should convert the values to px by yourself. The constructor expects absolute pixel values.

The following listener settters are a copy of GoogleMap's setters. Use these methods instead of the original ones.

  • public void setOnMapClickListener(GoogleMap.OnMapClickListener onMapClickListener)
  • public void setOnCameraIdleListener(GoogleMap.OnCameraIdleListener onCameraIdleListener)
  • public void setOnCameraMoveStartedListener(final GoogleMap.OnCameraMoveStartedListener onCameraMoveStartedListener)
  • public void setOnCameraMoveListener(final GoogleMap.OnCameraMoveListener onCameraMoveListener)
  • public void setOnCameraMoveCanceledListener(final GoogleMap.OnCameraMoveCanceledListener onCameraMoveCanceledListener)

Known issues

The InfoWindow lags when you fling the map. However if you want to hide it instead of moving it with the map, you can use InfoWindowManager.setHideOnFling(final boolean hideOnFling). We are open to suggestions how to fix this.

License

Copyright 2016 Appolica Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Resources

A Reactive Bus library.

Minion is a blazing-fast, simple to use and handy group-key-value data storage library, powered by INI format.

Let you parse and store INI format. Designed with modern fluent interface.

The goal of this library is to help you in your development of User Interface. This library will give you scrolling background effect as shown in the below image.

Finding current location cannot be easier on Android !

  • RxJava2 compatible
  • Automatically ask for gps runtime permissions
  • Check if play services are available for you

Library for Event bus - implemented using RxJava2 in Android.

Very compact library to handle android dynamic permissions. Contrary to other solutions, it supports modal and modeless rationale.

Features

  1. single-file implementation, if you want to pull it inside your project
  2. based on state machine, so fixing corner cases should be very easy
  3. modal rationale (using dialog)
  4. mode-less rationale (being integrated into screen itself)
  5. focused on permission handling logic - doesn't contain any UI code
  6. handles permissions revoked at runtime via settings menu
  7. handles permissions granted at runtime via settings menu

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes