How to add a tile overlay to MKMapSnapshotter? - swift

Is there any way to get a map snapshot with a tile overlay, for example for sharing or widgets?
MKMapView contains an addOverlay function that adds an MKTileOverlay overlay to the map. This is easy to do.
It is not possible to get a snapshot of such a composite view.
To get a snapshot of the map I used MKMapSnapshotter, which simply supplies a snapshot of any map slice. However, MKMapSnapshotter only gives the original map. If I need to add a layer, I have to draw it into the map snapshot. For simple layers like icons this is easy. But I don't know how to do it at all with a tile overlay.
I suppose I need to use MKTileOverlay to get an overlay image for the same area as the map snapshot. It is not a problem to merge such images. Unfortunately I don't know how to get it.
How to get a map image with a tile overlay?

Related

Tableau Dynamic Map Labelling

The map I'm making has the labels for markers overlapping unless I zoom in so much that only a small section of the map is visible. I'm presenting the map as one static picture of the entire state that is supposed to show all of the marker labels. Is there a way I can display a view of the map that will show the entire state I'm trying to display in one image with all of the marker labels visible? Here is what it looks like now

How to make scrollable and zoomable custom map on Apple Watch?

ViewRanger has a custom map which can be zoomed and scrolled on the Apple Watch. I didn't find any way to add extra layers to WKMapView. The emphasis is on "custom", so I want to have a topological map with my own tile /vector source. How can I create something similar?
You have to track gestures separately and call setRegion(_ coordinateRegion: MKCoordinateRegion) method on your WKInterfaceMap object to scroll/zoom map.

Leaflet: Lazy load mapbox tiles

How can I lazyload map tiles when using Leaflet?
Especially on mobile devices I don't want to load maptiles at the beginning because most of my users never scroll down to the map.
Well, a very simple trick would be to create your map, or at least to add your Tile Layer, only when your map container comes into viewport.
That way, the tiles will not be requested before the map is actually viewable.
As to how to know when this situation happens, you should find plenty resources online and here. Basically you compare the document scroll and the map container position, and listen to scroll event. A more recent solution uses Intersection Observer.
L.tileLayer(this.settings.tiles + '/{z}/{x}/{y}.jpg', {...})
.on('tileloadstart', function(event) {
event.tile.setAttribute('loading', 'lazy');
});

continuous drag or scaling in leaflet

at present our project is using the leaflet, I take the map parameters to background program (map.getZoom() and map.getbounds()) , then load the returned picture(return from background program) by imageoverlay.
excuse me how to solve continuous drag or continuous scaling, only the implementation of calling a daemon?
If you mean you dynamically load the base map (i.e. the image that is zoomable, draggable and that fills a big pane, not just a small portion that would have needed a single image overlay), you should probably rather do it through a Canvas Tile Layer:
Used to create Canvas-based tile layers where tiles get drawn on the browser side.
With this, you set up a myCanvasTileLayer.drawTile function that is called by Leaflet anytime the map needs more tiles (due to user panning / zooming). Please refer to Leaflet doc for the function arguments.
If you want to stick with your image overlay technique, you might want to listen to drag and zoomend map events to re-trigger your function that loads a new image overlay.

how to prevent wrapping of world map in mapbox?

I am using mapbox and featureGroup control.
World map is repeating horizontally.How can I prevent horizontal repeating of world map.
I have tried 'no-wrap:true' ,but this seems to work only for tile layer.
For featureGroup,Please suggest some way.
var map = L.mapbox.map(mapData, MapBoxAccess.mapBoxAccess.accessId);
var featureGroup = L.featureGroup().addTo($scope.map);
I am adding my polygons and polylines on featureGroup
Please find attached image for better understanding.
That actually is the intended behavior and features cannot repeat across the globe like this. If you wanted to prevent scrolling across the globe, you can set bounds over the map so that someone can't scroll or pan side to side. Also, there is a Leaflet method called WorldCopyJump which will also bounce the view back to the bounds.