I'm trying to create a static image using the "auto" feature to correctly calibrate the image according to the polyline I pass to it. It works very well but I'd like to add a pitch in addition.
I've tried something like this but I got this error: "Invalid query param pitch"
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/pin-s-a+9ed4bd(-122.46589,37.77343),pin-s-b+000(-122.42816,37.75965),path-5+f44-0.5(%7DrpeFxbnjVsFwdAvr#cHgFor#jEmAlFmEMwM_FuItCkOi#wc#bg#wBSgM)/auto/500x300?access_token=xxxxx&pitch=50
Any help please ?
The auto parameter automatically sets the values for longitude, latitude, zoom, bearing, and pitch based on the overlay. When using auto you cannot set these values individually as the parameter replaces all of their values with the best settings for the overlay. From the documentation:
If auto is added, the viewport will fit the bounds of the overlay. If
used, auto replaces lon, lat, zoom, bearing, and pitch.
If you'd like to set the pitch, you will need to supply your own values for longitude, latitude, zoom, and bearing as well. For example: https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/pin-s-a+9ed4bd(-122.46589,37.77343),pin-s-b+000(-122.42816,37.75965),path-5+f44-0.5(%7DrpeFxbnjVsFwdAvr#cHgFor#jEmAlFmEMwM_FuItCkOi#wc#bg#wBSgM)/-122.46589,37.75965,11,0,50/500x300?access_token={YOUR_ACCESS_TOKEN}
Will return:
Related
My question is about mapbox gl js.
How to change map fill-color by current zoom level?
The fill-color of this map has population growth rates by country, with a gradation from minimum to maximum. However, if the zoomed location has similar data, the fill-color difference becomes difficult to understand. So, I want to refer to the tile information according to the zoom level, get the country on the screen, and redraw it.
I searched a lot, but I couldn't figure out how to get the information on the screen. Please let me know if you have any information.
Zoom Level: 1
Zoom Level: 3
Thank you!
Your question initially asks:
How to change map color by current zoom level with mapbox gl js?
For that, you use an expression like 'fill-color': ['interpolate', ['linear'], ['zoom'], ...]
But what you want is something very different:
However, if the zoomed location has similar data, the fill-color difference becomes difficult to understand. So, I want to refer to the tile information according to the zoom level, get the country on the screen, and redraw it.
It sounds like what you want is context-sensitive color scaling. That is, instead of a fixed scale of colors where dark green always means X and light green means Y, instead, dark is the lowest value in the current viewport and light is the highest value in the viewport.
This does not have anything to do with zoom.
The steps you need are:
Detect when the viewport has changed: map.on("moveend", ...)
Find what values exist within the viewport: map.queryRenderedFeatures(...)
Calculate a new expression based on those values.
Set the new expression: map.setPaintProperty(...)
I'm trying to find out what is the bounding box of the visible part of google map in flutter's google maps plugin.
Is it possible to get it?
If not is it possible to calculate the bounding box based on zoom level and latitude, longitude of the map center?
That would be GoogleMapController.getVisibleRegion()
Be careful, GoogleMapController.getVisibleRegion() returns a LatLngBounds (a rectangle) and if your map has a tilt then it should not be a rectangle but a trapezoid!
The issue is in the plugin implementation where the returned result is computed only from latLngBounds field whereas it should be computed from farLeft, farRight, nearLeft, nearRight fields.
Reference: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/VisibleRegion
So GoogleMapController.getVisibleRegion() is not accurate and can't be used if there's a tilt.
For reference, an issue has been created: https://github.com/flutter/flutter/issues/74888
I have Leaflet map with leaflet-routing-machine. I set few waypoints and all work fine.
But now I want alter the way. I drag it, map set additional waypoint and now route goes through this extra point.
How can I understand that this waypoint is 'extra' one (not includes in predefined set of points) in instructions properties of route . Maybe I can set special label for it?
I have lat, lng for my predefined points, but I want have distance between all MY points.
How can I convert zoom lavel to altitude?
There is some kind of function
or algorithm or table of values?
There is a draft PR at https://github.com/mapbox/mapbox-gl-js/pull/8830 which adds a method to set the camera with an altitude, you could pull out some of that code to make your own method which returns a zoom level given an altitude.
I need to display on the map a scale showing how far a inch / cm is for example. This will need to change depending on the zoom level.
My theory is that if I know the length of the map, and the length of the graphic, If I know what the current scale of the map was I could just do some maths to work out the graphic indicator scale.
So is there a way to get the current zoom lvl in meters? Is it linked to the span or something?
The zoom level is linked to the span - you first need to get the span of your map view, and then convert it into meters.