ExtraMapUtils


Source link: https://github.com/bkhezry/ExtraMapUtils

simple library for handle markers, polygons and polylines on google maps.

ExtraMapUtils is an android library to make working with map markers, polygon and polyline drawing on googlemaps, more convenient.

Project Setup and Dependencies

  • JDK 8
  • Android SDK Build tools 25.0.2
  • Supports API Level +17
  • AppCompat & Cardview libraries 25.3.0
  • Google Play Services Maps 10.2.0

Highlights

  • Provides multiple themea to apply on MapView
  • Add multiple markers, polygons & polylines easily
  • Supports vector drawable for marker icon
  • Supports Lite Mode
  • Supports calculating area of polygon & length of polyline
  • Supports GeoJson & KML as layer from url or resource file

Preview

Demo

You can download the latest demo APK from here: https://github.com/bkhezry/ExtraMapUtils/blob/master/assets/DemoExtraMapUtils.apk

Screenshots

Setup

1. Provide the gradle dependency

Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {

...
maven {
 url "https://jitpack.io" 
}
  
}
 
}

Add the dependency:

dependencies {
  compile 'com.github.bkhezry:ExtraMapUtils:v1.2.0' 
}

2. Add your code

add MapView to UI layout

<com.google.android.gms.maps.MapView  android:id="@+id/mapLite"  android:name="com.google.android.gms.maps.MapFragment"  android:layout_width="match_parent"  android:layout_height="300dp"  app:liteMode="true"  app:mapType="normal" />
new ViewOptionBuilder()  .withStyleName(ViewOption.StyleDef.RETRO)  .withCenterCoordinates(new LatLng(35.6892, 51.3890))  .withMarkers(AppUtils.getListExtraMarker())  .withPolygons(
AppUtils.getPolygon_1()  )  .withPolylines(
AppUtils.getPolyline_2(),
AppUtils.getPolyline_4()  )  .withForceCenterMap(false)  .build();

after declaring the ViewOption, add this code for showing elements on the MapView

 MapUtils.showElements(viewOption, googleMap, getActivity());

ViewOption attributes

Name Type Default Description
title String @NullAble use in demo as CardView tile
centerLatLng LatLng @NullAble center of Map
forceCenterMap boolean false force map moving to centerLatLng point
mapsZoom float 14 zoom of map when map moving to centerLatLng
markers ExtraMarker @NullAble list of ExtraMarker that showing on Map
polygons ExtraPolygon @NullAble list of ExtraPolygon that showing on Map
polylines ExtraPolyline @NullAble list of ExtraPolyline that showing on Map
isListView boolean false when using utils in ListView this parameter should be true. because fixing zoom of bounded map
styleName StyleDef DEFAULT style of google map

declare ExtraMarker

new ExtraMarkerBuilder()  .setName("Start")  .setCenter(latLngs_3[0])  .setIcon(icons_2[0])  .build()

ExtraMarker attributes

Name Type Default Description
name String @NullAble label of Marker
center LatLng @NoneNull center of Marker
icon int @NoneNull icon of marker

delare ExtraPolygon

new ExtraPolygonBuilder()  .setPoints(latLngs_1)  .setzIndex(0)  .setStrokeWidth(10)  .setStrokeColor(Color.argb(100, 0, 0, 0))  .setFillColor(Color.argb(100, 200, 200, 200))  .build();

ExtraPolygon attributes

Name Type Default Description
points LatLang[] @NoneNull list of point
fillColor int none color color of polygon filling
uiOptions UiOption @NoneNull some parameter of polygon

declare ExtraPolyline

 new ExtraPolylineBuilder()

  .setPoints(latLngs_2)

  .setzIndex(0)

  .setStrokeWidth(10)

  .setStrokeColor(Color.argb(100, 255, 0, 0))

  .build();

ExtraPolyline attributes

Name Type Default Description
points LatLang[] @NoneNull list of point
uiOptions UiOption @NoneNull some parameter of polyline

UiOption attributes

Name Type Default Description
strokeColor int Color.BLACK line color
strokeWidth int 10 width of line
zIndex int 0 zIndex of polyline or polygon
strokePattern StrokePatternDef Default stroke pattern of line

getArea() method in ExtraPolygon return Area of polygon in square meters. getLength method in ExtraPolyline return Length of polyline in meters.

add GeoJson to ViewOption

new ViewOptionBuilder()

.withTitle("GeoJson")

.withGeoJson(context.getString(R.string.geo_json_url))

.withStyleName(ViewOption.StyleDef.DEFAULT)

.withGeoJsonEventListener(new onGeoJsonEventListener() {

@Override
public void onFeatureClick(Feature feature) {

 //Do more things.

}

 @Override
public void onGeoJsonLoaded(GeoJsonLayer geoJsonLayer) {

 AppUtils.addColorsToMarkers(geoJsonLayer);

}

}
)

.withIsListView(true)

.build();

Todo

  • clustering support for markers
  • add GeoJson & KML layers to map
  • add more demo for mixed elements.
  • javadoc
  • ...

Developed By

License

Copyright 2017 Behrouz Khezry  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

ProductTour is android sample project implementing a parallax effect welcome page using PageTransformer, similar to the one found in google's app like Sheet, Drive...

This is an amazing image slider for the Android platform. You can easily load images from an internet URL, drawable, or file, and there are many kinds of amazing animations you can choose.

An open source Meh app for Android.

Goreinu allows to copy application files on sdcard.

Evernote SDK for Android.

A fun to play quiz that showcases material design on Android.

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