IOS - Calculating tiles to display in a MapRect when - iphone

I have tried the solution on this but get 2 errors when I run the build. First "MAX_ZOOM undeclared" and Implicit declaraation of function'zoomScaleToZoomLevel'
I'm new to xCode, any help? need to fix tile zooming.
Thanks Ken
Calculating tiles to display in a MapRect when "over-zoomed" beyond the overlay tile set

MAX_ZOOM is a constant - you need to define it someplace in your code to match the number of zoom levels in your tile set.

Related

Spacing between heatmap point

I tried to customise leaflet heatmap.js to render rectangles to generate a heatmap. I was doing good so far. But, there are spacing in between rectangles that I can't get rid of. As in the picture.
heatmap
Solutions that I tried: turn off antialiasing, add offset. While adding offset remove the space, it creates an area with "blended color" which I don't want to have. I wonder if there is a solution to remove the gap or remove the blending color in heatmap.js.
Thanks and regards.
Turn out it is precision problem of the leaflet latlong to screen coordinate function. I have fixed it by recalculate the coordinate.

Setting the CRS for non-geographical svg map

I'm trying to show a custom non-geographical map with CRS.simple as explained here:
In a CRS.Simple, one horizontal map unit is mapped to one horizontal
pixel, and idem with vertical
However, I wish to use an SVG vector image as an overlay, but I don't get how the map unit is decided in this case, since the vector images don't really have a resolution?
Also, how could set the CRS origin's location to a specific point?
Thanks for helping

How to fit bounds and set max bounds at same time on window resize in MAPBOX?

To fit the map we use mapbox.fitBounds() and to set we do mapbox.setMaxBounds(), which avoid panning. This work's perfectly well on first load.
But on Window resize map get cropped and take the bounds reference from initially set maxbounds. I am trying to fit the map in viewport using setTimeout, so that map first fit on screen and then getting map bounds from mapbox.getBounds() set the value in mapbox.setMaxBounds(). But this is just an hack.
Is there any correct way to do so?
Please help... and thank you..
Hope you are all well...
After many days of struggle, we are able to find the perfect solution, for my own question posted...
Firstly,
mapbox.fitBounds() is the method on passing given bounds as args, will fit the geometry(polygon etc..), making the center point in the middle. But the only thing it does not disallow panning.
However, we can disallow panning using mapbox.setMaxBounds() which allow us to constrained to passed bounds.
But on window resize, somehow mapbox Map change the bounds as per internal logic, which will no longer be the same as passed bounds initially...
In order to fit the geometry on the viewport, at the same time disallow panning on window resize, we use Resize Observer to observe map's container, and in its callback, we just wrote, three lines
Set map.setMaxBounds(null) //to null
set fitbounds(bounds). //bounds of geometry that u have
Get bounds from viewport using
let bnds = mapbox.getBounds();
and finally set in map.setMaxBounds(bnds);
Note to pass the 3. point in requestAnimationFrame instead of setTimeout
UPDATED Code
MaxBounds and custom asymmetric padding in Mapbox GL
Hope this will help...
Thank you.

ios-charts - problems using autoScaleMinMaxEnabled

I try to auto scale the y-axis for an LineChart. If I set the option autoScaleMinMaxEnabled, followed by an notifyDataSetChanged no auto scale occurs.
Also toggeling autoScaleMinMaxEnabled in ChartsDemo seems not to work. Is there a special trick?
Many thanks! - Tino
The "trick" is that min/max of the Y-axis is determined dynamically, during scrolling, depending on the y-values that are contained in the visible x-range.
If you want to see it working in the demo, then zoom in, enable autoScaleMinMaxEnabled, and then scroll to the right. Watch the Y-axis.

mapkit: region that fits does not render correctly

I have a piece of code that determines both best region.span.latitudeDelta and region.span.longitudeDelta. It finds the top left and bottom right and takes the diff between lat-coordinates and long-coordinates.
The problem I have is that rendering actually differs than what I set when executing:
region = self.regionThatFits(region)
self.setRegion(region, animated: true)
As an example, if I first select the items I want to render (let's say from a table) and then switch to the map I get a different result (visually) than showing all points on the map and then selecting the ones I want to keep.
Even more, if I render all points on the map, then select a few and render selected, then remove filters and render all, the map is not the same as it was when I started - it shows all the points but it is smaller (looks zoomed out) in comparison to the initial view.
On debugging I can see that both scenarios generate the same span values but it is as if rendering ignores them. From debug using (the selected points in the UK):
Load all points:
region.span.latitudeDelta 7.439768
region.span.longitudeDelta 11.0
Filter points:
region.span.latitudeDelta 1.25
region.span.longitudeDelta 10.50477
Remove filter:
region.span.latitudeDelta 7.439768
region.span.longitudeDelta 11.0
I tried re-centering the map on a fixed coordinate before I re-render (instead of just on viewDidLoad) but it made no difference.
I would like to highlight that the map does not keep zooming out every time I run the above sequence. It kind of zooms out once and that's it.
Is there an obvious step that I am missing? A hidden Boolean that I need to set? Something else?
I also tried changing from regionThatFits to
regionToRender = MKCoordinateRegionMake(region.center, region.span)
And I tried the following too:
func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
self.mapView.region = mapView.region
}
No matter what I do, if I apply the annotation filter when I am already on the map it looks as if actual span is increased/doubled (or as if there is a forced frame around the map edges) making the map look as if it is zoomed out despite the debug output showing otherwise...
Below are the two images from the different scenarios. Any advice will be greatly appreciated.
Thanks!
Picture 1 - applied filter while I was in a table and then navigated to map:
Picture 2 - navigated to map and then applied filter:
Upon extensive debugging covering layouts, frames and bounds among other things, this is what is happening:
When the ViewController containing the map is loaded for the first time, the map does not actually fit the view. To be precise it is loaded in its free form which is effectively 600x492 WxH respectively. Height of 492 is simply:
free form height - NavCon Height - ToolBar Height - default margin (battery etc.)
After the first pass of rendering annotation (effectively in viewDidAppear), the MapView gets the correct height (on iphone 4s) of 372. This is simply:
screen height (480) - NavCon Height - ToolBar Height - default margin
As a result, any rendering from this point will result in a zoom-out like effect (making everything look smaller).
The solution is to calculate the size which the mapView will get and set in viewDidLoad. In addition, you should probably also set the mapView autoresizing mask to match the parent view:
self.mapView.autoresizingMask = self.view.autoresizingMask
I hope you find this helpful.