googlemaps / googlemaps/google-maps-services-java

[Google Static Maps] Handle styled Maps with the "style" parameter

オープン
#826 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
triage me type: feature request
主要言語
Java
スター
1.8k
フォーク
973
PR マージ指標
30日以内にマージされた PR はありません

説明

I use the Google Static Maps API and I would like to customize the presentation of the Map by applying my own styles.

I found this documentation: https://developers.google.com/maps/documentation/maps-static/styling

**Is your feature request related to a problem? Please describe.**

But I can't find a method in `StaticMapsRequest.java` to add styles.

As an alternative, I used `StaticMapsRequest.custom(...)` method.

```
req.custom("style", "feature:poi|visibility:off");
```

But I can't add multiple styles, because the `custom` method allows to add just one 'style' parameter.

I can't do the following:
```
StaticMapsRequest req = StaticMapsApi.newRequest(sc.context, new Size(WIDTH, HEIGHT));
req.center("Google Sydney");
req.zoom(16);

req.custom("style", "feature:poi|visibility:off");
req.custom("style", "feature:landscape|visibility:off");

ByteArrayInputStream bais = new ByteArrayInputStream(req.await().imageData);
BufferedImage img = ImageIO.read(bais);
```

**Describe the solution you'd like**
I would like to have a method to handle the 'style' parameter.
```
req.style(
new Style()
.feature(new StyleFeature().poi())
.element(new StyleElement().labels().icon())
.rules(new StyleRules().color(java.awt.Color.WHITE))
);
req.style(
new Style()
.feature(new StyleFeature().landscape().man_made())
.rules(new StyleRules().visbility().off())
);
```

**Describe alternatives you've considered**
The `custom` method allows to add a single string:
```
public A custom(String parameter, String value) {
return this.param(parameter, value);
}
```
An alternative would be to add a new `custom` method that allows a list of Strings:
```
public A custom(String parameter, List values) {
values.forEach(v -> this.paramAddToList(parameter, v));
return this.getInstance();
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。