All Projects → sarweshkumar47 → Curve Fit

sarweshkumar47 / Curve Fit

Licence: apache-2.0
Curve-Fit is an Android library for drawing curves on Google Maps

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Curve Fit

carto-react
CARTO for React packages
Stars: ✭ 17 (-73.02%)
Mutual labels:  maps, google-maps
EasyWayLocation
This library contain all utils related to google location. like, getting lat or long, Address and Location Setting dialog, many more...
Stars: ✭ 142 (+125.4%)
Mutual labels:  maps, google-maps
SimplePlacePicker
Android place picker module for searching and selecting a location on google maps
Stars: ✭ 42 (-33.33%)
Mutual labels:  maps, google-maps
Dual-color-Polyline-Animation
This library will help to show the polyline in dual color similar as Uber.
Stars: ✭ 73 (+15.87%)
Mutual labels:  maps, google-maps
Leku
🌍 Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
Stars: ✭ 612 (+871.43%)
Mutual labels:  google-maps, maps
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (+4165.08%)
Mutual labels:  maps, google-maps
google-maps-at-88-mph
Google Maps keeps old satellite imagery around for a while – this tool collects what's available for a user-specified region in the form of a GIF.
Stars: ✭ 93 (+47.62%)
Mutual labels:  maps, google-maps
trackanimation
Track Animation is a Python 2 and 3 library that provides an easy and user-adjustable way of creating visualizations from GPS data.
Stars: ✭ 74 (+17.46%)
Mutual labels:  maps, google-maps
Flask Googlemaps
Easy way to add GoogleMaps to Flask applications. maintainer: @RiverFount
Stars: ✭ 550 (+773.02%)
Mutual labels:  google-maps, maps
Jquery Store Locator Plugin
A store locator plugin using Google Maps API version 3
Stars: ✭ 471 (+647.62%)
Mutual labels:  google-maps, maps
HealthCare-Scan-Nearby-Hospital-Locations
I developed this android application to help beginner developers to know how to use Google Maps API and how to convert JSON data into Java Object.
Stars: ✭ 23 (-63.49%)
Mutual labels:  maps, google-maps
Sketch Map Generator
Sketch plugin to fill a shape with a map generated from a given location using Google Maps and Mapbox
Stars: ✭ 824 (+1207.94%)
Mutual labels:  google-maps, maps
map-kit-android
An extensive framework for map development in Android.
Stars: ✭ 44 (-30.16%)
Mutual labels:  maps, google-maps
google-streetview-images
Pull google streetview panoramic images along a route.
Stars: ✭ 45 (-28.57%)
Mutual labels:  maps, google-maps
activeadmin-latlng
Active Admin plugin for setting up latitude and longitude
Stars: ✭ 34 (-46.03%)
Mutual labels:  maps, google-maps
carto-react-template
CARTO for React. The best way to develop Location Intelligence (LI) Apps usign CARTO platform and React
Stars: ✭ 24 (-61.9%)
Mutual labels:  maps, google-maps
GoogleMapsHelper
An easy to integrate Model Based Google Maps Helper (SVHTTPClient, AFNetworking) That lets you Geo Code , Reverse Geocode, Get Directions , Places Autocomplete.
Stars: ✭ 21 (-66.67%)
Mutual labels:  maps, google-maps
js-markerclusterer
Create and manage clusters for large amounts of markers
Stars: ✭ 92 (+46.03%)
Mutual labels:  maps, google-maps
polylineencoder
A C++ implementation of Google Encoded Polyline Algorithm Format (encoder/decoder)
Stars: ✭ 15 (-76.19%)
Mutual labels:  maps, google-maps
Gmaps
Google maps for Jupyter notebooks
Stars: ✭ 705 (+1019.05%)
Mutual labels:  google-maps, maps

Curve-Fit

Android Arsenal Release License

Android library for drawing curves on Google Maps. This library uses Bezier cubic equation in order to compute all intermediate points of a curve.

Changes

  • Please note that this release only works with Google Maps Android SDK v2. If you are experimenting with Google Maps Android SDK 3.0.0 BETA, try using CurveFit-2.0.0-beta
  • [bug] Fixed (#4) (#6)

Demo

demo sample_india sample_denmark

Setup

Gradle

dependencies {
    implementation 'com.github.sarweshkumar47:curve-fit:1.1.1'
}

Maven

<dependency>
 <groupId>com.github.sarweshkumar47</groupId>
 <artifactId>curve-fit</artifactId>
 <version>1.1.1</version>
 <type>pom</type>
</dependency>

JitPack

allprojects {
    repositories {
    ...
    maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.sarweshkumar47:Curve-Fit:version_1_1_1'
}

Usage

In your activity's onCreate() method, use getMapAsync() to register for the map callback. Implement OnMapReadyCallback, OnCurveDrawnCallback, OnCurveClickListener interfaces and override the onMapReady() method

@Override
public void onMapReady(GoogleMap googleMap) {

    // Create a CurveManager object and pass googleMaps reference to it
    curveManager = new CurveManager(googleMap);

    // Register a callback to be invoked after curve is drawn on map
    curveManager.setOnCurveDrawnCallback(this);
    
    // Set a listener for curve click events.
    curveManager.setOnCurveClickListener(this);
        
    // Create a CurveOptions object and add atleast two latlong points to it
    // You can set different options in CurveOptions object similar to PolyLineOptions
    CurveOptions curveOptions = new CurveOptions();
    curveOptions.add(new LatLng(12.9715987, 77.5945627));
    curveOptions.add(new LatLng(12.2958104, 76.6393805));
    curveOptions.color(Color.DKGRAY);
    curveOptions.setAlpha(0.5f);
    curveOptions.width(12);
    List<PatternItem> pattern = Arrays.asList(new Dash(30), new Gap(30));
    curveOptions.pattern(pattern);
    curveOptions.geodesic(false);

    map.addMarker(new MarkerOptions().position(sourceLatLng).anchor(0.5f, 1f));
    map.addMarker(new MarkerOptions().position(destinationLatLng).icon(BitmapDescriptorFactory
            .defaultMarker(BitmapDescriptorFactory.HUE_GREEN)).anchor(0.5f, 1f));

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(12.64779202, 77.16562563), 14));
    
    // Draws curve asynchronously
    curveManager.drawCurveAsync(curveOptions);
}

Remove listeners in order to prevent memory leaks.

@Override
protected void onDestroy() {
    if (curveManager != null) {
        curveManager.unregister();
        curveManager = null;
    }
    if (map != null) {
        map.stopAnimation();
        map.clear();
        map = null;
    }
    if (mapFragment != null) {
        mapFragment.getMapAsync(null);
        mapFragment = null;
    }
    super.onDestroy();
}

Check example projects for more info.

Advanced usage

CurveOptions

  • Alpha
CurveOptions setAlpha(float alpha)

Defines shape and deviation of a curve. Alpha can vary from -1 to 1. The below images demonstrate how alpha value is used to define the shape and deviation of a curve in the algorithm (default value is 0.5).

alpha_negative

Note: This behaviour may vary when a curve passes through 180 degree meridian. Sometimes, you may not get a perfect curve. In that case, use setComputePointsBasedOnScreenPixels(true) method to get the desired curve.

  • ComputePointsBasedOnScreenPixels
CurveOptions setComputePointsBasedOnScreenPixels(boolean computePointsBasedOnPixels)

If set to true, geographic location points will be converted to screen pixel points and algorithm uses screen pixel points to compute all intermediate curve points. Refer the below image to understand the variations.

Note: Method setComputePointsBasedOnScreenPixels(true) gives a perfect curve regardless of the geographical locations. But it has certain limitations. This method requires more computation time. Sometimes, you may a get a strangely shaped curve when the two lat-long points are off the screen (outside the visible region) or when two points are too close at lower zoom levels. Workaround to this problem is to compute the lat-long bounds and zoom the map camera towards the center of the bounds.

Contributions

Contributions are welcome and much appreciated.

Credit

Icons and images

License

Copyright 2018 Sarweshkumar C R

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].