https://github.com/alexcheng1982/gaode-static-map
Gaode Static Map URL Generator
https://github.com/alexcheng1982/gaode-static-map
gaode gaodemap map
Last synced: about 1 year ago
JSON representation
Gaode Static Map URL Generator
- Host: GitHub
- URL: https://github.com/alexcheng1982/gaode-static-map
- Owner: alexcheng1982
- License: apache-2.0
- Created: 2024-03-26T07:12:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T09:03:31.000Z (about 2 years ago)
- Last Synced: 2024-04-17T02:01:09.867Z (about 2 years ago)
- Topics: gaode, gaodemap, map
- Language: Java
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Gaode Static Map URL Generator (高德静态地图URL生成器)
[](https://github.com/alexcheng1982/gaode-static-map/actions/workflows/build.yaml)
[](https://central.sonatype.com/artifact/io.github.alexcheng1982/gaode-static-map)
Generate URL
for [Gaode Static Maps](https://developer.amap.com/api/webservice/guide/api/staticmaps/).
生成高德地图的静态地图的URL.
Requires Java 8.
A [Gaode API key](https://lbs.amap.com/api/webservice/create-project-and-key) is
required to render the map.
Add the
following [Maven dependency](https://central.sonatype.com/artifact/io.github.alexcheng1982/gaode-static-map)
to your project.
```xml
io.github.alexcheng1982
gaode-static-map
1.2.0
```
Build a `StaticMap` and pass to `StaticMapGenerator.generate()` to generate the
URL.
```java
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`.