Giter Club home page Giter Club logo

gmappolyline's Introduction

Polyline functions for Google Maps

The library contains some useful utils for encoding Polylines for Google Maps, checking point into the circle, etc.

The code is working according to the real Globe form - Geoid (https://en.wikipedia.org/wiki/Geoid) not a sphere!

For sample usage, see PolylineTest.java:

    public void testApp()
    {
        
        final int numberOfPoints = 8; // Octagon

        // CENTER = Riga, Peldu iela
        final int radiusInMeters = 50;
        final double latitude = 56.946345;
        final double longitude = 24.108515;

        final List < LatLng > latLngs = PolyUtil.prepareCircleFromRadius(new LatLng(latitude, longitude), radiusInMeters, numberOfPoints);

        final String encode = PolyUtil.encode(latLngs);
        System.out.println("Encoded Polyline for Google Map = "+encode);

        String staticMapImageUrl = "https://maps.googleapis.com/maps/api/staticmap?size=400x400&center=%s,%s&zoom=16&path=fillcolor:0x00000033|color:0xFF0000|enc:%s";

        System.out.println("URL of static image = "+String.format(staticMapImageUrl, latitude, longitude, encode));

        // Contains location test:
	// "Is LatLng(56.946412, 24.108729) inside the circle?"
        assertTrue(PolyUtil.containsLocation(new LatLng(56.946412, 24.108729), latLngs, true)); // Should be TRUE
        
	// "Is LatLng(56.94693, 24.108316) inside the circle?"
	assertFalse(PolyUtil.containsLocation(new LatLng(56.94693, 24.108316), latLngs, true)); // Should be FALSE
		
    }

Commands:

Build JAR: mvn clean package

Hot to use your new library:

Newly created library may be used directly, placed into maven repository, if needed, or used from GitHub like this:

  1. Add jitpack.io repository to your POM file:
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
  1. Add dependency to POM:
        <dependency>
            <groupId>com.github.divlv</groupId> <!-- Your GitHub login (divlv) -->
            <artifactId>gmappolyline</artifactId> <!-- Your GitHub repo name (of library) -->
            <version>1.0</version> <!-- GitHub lib release version -->
        </dependency>
  1. Enjoy!

gmappolyline's People

Contributors

divlv avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.