Skip to content

Commit ff47ca2

Browse files
committed
Add example for freely positioned pins
1 parent 8f3df08 commit ff47ca2

File tree

8 files changed

+41
-2
lines changed

8 files changed

+41
-2
lines changed

Images/CenteredPins.png

119 KB
Loading

Images/FreePins.png

52.8 KB
Loading

Images/Labels.png

59 KB
Loading

Images/Pins.png

-78.9 KB
Binary file not shown.

Images/SimpleMap.png

40.8 KB
Loading

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ StaticMap(center: .init(latitude: 51.5, longitude: 0))
1717

1818
![Simple Map](Images/SimpleMap.png)
1919

20-
### Pins
20+
### Centered Pins
2121

2222
```swift
2323
StaticMap(
@@ -32,7 +32,23 @@ StaticMap(
3232
)
3333
```
3434

35-
![Pins](Images/Pins.png)
35+
![Centered Pins](Images/CenteredPins.png)
36+
37+
### Free Pins
38+
39+
```swift
40+
StaticMap(
41+
annotations: [
42+
.pin(coords: .init(latitude: 58.8, longitude: -3.3)),
43+
.pin(coords: .init(latitude: 54.2, longitude: -4.5)),
44+
.pin(coords: .init(latitude: 52.5, longitude: -1.9)),
45+
.pin(coords: .init(latitude: 51.1, longitude: -2.3)),
46+
.pin(coords: .init(latitude: 51.5, longitude: 0.0)),
47+
]
48+
)
49+
```
50+
51+
![Free Pins](Images/FreePins.png)
3652

3753
### Labels
3854

File renamed without changes.

Snippets/FreePins.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Foundation
2+
import Geodesy
3+
import StaticMap
4+
5+
guard CommandLine.argc == 2 else {
6+
print("Usage: \(CommandLine.arguments[0]) <output path>")
7+
exit(1)
8+
}
9+
10+
let outputPath = CommandLine.arguments[1]
11+
12+
let staticMap = StaticMap(
13+
annotations: [
14+
.pin(coords: .init(latitude: 58.8, longitude: -3.3)),
15+
.pin(coords: .init(latitude: 54.2, longitude: -4.5)),
16+
.pin(coords: .init(latitude: 52.5, longitude: -1.9)),
17+
.pin(coords: .init(latitude: 51.1, longitude: -2.3)),
18+
.pin(coords: .init(latitude: 51.5, longitude: 0.0)),
19+
]
20+
)
21+
let image = try await staticMap.render()
22+
23+
try image.pngEncoded().write(to: URL(fileURLWithPath: outputPath))

0 commit comments

Comments
 (0)