Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Kobee1203 opened this issue May 12, 2022 · 5 comments
Open
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Kobee1203
Copy link

Kobee1203 commented May 12, 2022

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<String> values) {
    values.forEach(v -> this.paramAddToList(parameter, v));
    return this.getInstance();
}
@Kobee1203 Kobee1203 added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 12, 2022
@Kobee1203 Kobee1203 changed the title [Google Static Maps] Handle styles Maps with the "style" parameter [Google Static Maps] Handle styled Maps with the "style" parameter May 12, 2022
@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Sep 21, 2022
@Kobee1203
Copy link
Author

...

@stale stale bot removed the stale label Jan 30, 2023
@stale
Copy link

stale bot commented Jun 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Jun 18, 2023
@BesitecMH
Copy link

It is still valid.

@stale stale bot removed the stale label Mar 22, 2024
@BesitecMH
Copy link

This is what I did as a minimum workaround:

public final class MyStaticMapsRequest extends StaticMapsRequest {
	/**
	 * Instantiates a new my static maps request.
	 *
	 * @param context the context
	 */
	private MyStaticMapsRequest(GeoApiContext context) {
		super(context);
	}

	/**
	 * Of.
	 *
	 * @param context the context
	 * @param size the size
	 * @return the my static maps request
	 */
	public static MyStaticMapsRequest of(GeoApiContext context, Size size) {
		MyStaticMapsRequest request = new MyStaticMapsRequest(context);
		request.size(size);
		return request;
	}

	@Override
	public MyStaticMapsRequest center(LatLng location) {
		return (MyStaticMapsRequest) super.center(location);
	}

	@Override
	public MyStaticMapsRequest center(String location) {
		return (MyStaticMapsRequest) super.center(location);
	}

	@Override
	public MyStaticMapsRequest format(ImageFormat format) {
		return (MyStaticMapsRequest) super.format(format);
	}

	@Override
	public MyStaticMapsRequest maptype(StaticMapType maptype) {
		return (MyStaticMapsRequest) super.maptype(maptype);
	}

	@Override
	public MyStaticMapsRequest markers(Markers markers) {
		return (MyStaticMapsRequest) super.markers(markers);
	}

	@Override
	public MyStaticMapsRequest path(EncodedPolyline path) {
		return (MyStaticMapsRequest) super.path(path);
	}

	@Override
	public MyStaticMapsRequest path(Path path) {
		return (MyStaticMapsRequest) super.path(path);
	}

	@Override
	public MyStaticMapsRequest region(String region) {
		return (MyStaticMapsRequest) super.region(region);
	}

	@Override
	public MyStaticMapsRequest scale(int scale) {
		return (MyStaticMapsRequest) super.scale(scale);
	}

	@Override
	public MyStaticMapsRequest size(Size size) {
		return (MyStaticMapsRequest) super.size(size);
	}

	@Override
	public MyStaticMapsRequest visible(LatLng visibleLocation) {
		return (MyStaticMapsRequest) super.visible(visibleLocation);
	}

	@Override
	public MyStaticMapsRequest visible(String visibleLocation) {
		return (MyStaticMapsRequest) super.visible(visibleLocation);
	}

	@Override
	public MyStaticMapsRequest zoom(int zoom) {
		return (MyStaticMapsRequest) super.zoom(zoom);
	}

	/**
	 * Style.
	 *
	 * @param value The value of the custom parameter.
	 * @return Returns the request for call chaining.
	 */
	public MyStaticMapsRequest style(String value) {
		return (MyStaticMapsRequest) paramAddToList("style", value);
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants