GithubHelp home page GithubHelp logo

gaode-static-map's Introduction

Gaode Static Map URL Generator (高德静态地图URL生成器)

build Maven Central Version

Generate URL for Gaode Static Maps. 生成高德地图的静态地图的URL.

Requires Java 8.

A Gaode API key is required to render the map.

Add the following Maven dependency to your project.

<dependency>
  <groupId>io.github.alexcheng1982</groupId>
  <artifactId>gaode-static-map</artifactId>
  <version>1.2.0</version>
</dependency>

Build a StaticMap and pass to StaticMapGenerator.generate() to generate the URL.

GeoLocation center = GeoLocation.builder()
    .lat(39.990464)
    .lng(116.481485)
    .build();
GeoLocation p1 = GeoLocation.builder()
    .lat(40)
    .lng(116.5)
    .build();
GeoLocation p2 = GeoLocation.builder()
    .lat(40.05)
    .lng(116.8)
    .build();
StaticMap map = StaticMap.builder()
    .key("demo")
    .location(center)
    .zoom(10)
    .markers(Markers.builder()
        .markersGroups(Arrays.asList(
            MarkersGroup.builder()
                .style(MarkerStyle.builder()
                    .size(MarkerSize.LARGE)
                    .label("A")
                    .build())
                .locations(Arrays.asList(center))
                .build()
        ))
        .build())
    .labels(Labels.builder()
        .labelsGroups(Arrays.asList(
            LabelsGroup.builder()
                .style(LabelStyle.builder()
                    .content("Test")
                    .fontSize(16)
                    .build())
                .locations(Arrays.asList(center))
                .build()
        ))
        .build())
    .paths(Paths.builder()
        .pathsGroups(Arrays.asList(
            PathsGroup.builder()
                .locations(Arrays.asList(
                    center, p1, p2
                ))
                .build()
        ))
        .build())
    .build();
String url = StaticMapGenerator.generate(map);

The output url looks like https://restapi.amap.com/v3/staticmap?size=400*400&paths=5%2C0x0000FF%2C1.0%2C%2C%3A116.481485%2C39.990464%3B116.5%2C40.0%3B116.8%2C40.05&scale=1&location=116.481485%2C39.990464&zoom=10&markers=large%2C0xFC6054%2CA%3A116.481485%2C39.990464&key=demo&labels=Test%2C0%2C0%2C16%2C0xFFFFFF%2C0x5288d8%3A116.481485%2C39.990464&traffic=0.

gaode-static-map's People

Contributors

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