OpenLayer3 overlays displayed only on one map - openlayers-3

Im working with OpenLayer3 nad overlays. I created a few of them but when I zoomed out ( a few world maps are displayed), the overlays are displayed only on one one world map. But on the others world maps, they are not displayed.
How to fix it?

This is currently a limitation in OpenLayers 3 - vector layers do not support wrapping the world. A workaround would be to configure your tile layers to not wrap the world, using the wrapX: false config option.

wrapX, is now part of the current release of OpenLayers (v 3.2.0).
So if you want your layer to prevent multiple worlds. Just put it on your layer-source. See the example below:
tileLayer = new ol.layer.Tile({
source: new ol.source.OSM({
wrapX: false
})
});

Related

Is it possible to load a "blank" map in iOS MapKit?

I'm trying to build a mapping application that will be largely focused around custom tile overlays. Is it possible to load a map that does not contain a basemap layer, e.g. satellite or the basic map?
Desktop Apple Photos has an option to show the "grid" but that doesn't seem to exist in the MKMapType docs. Nor can you set map.mapType to nil.
Any ideas?
I haven't played with it yet, but it looks like there are some MKTileOverlay and MKTileOverlayRenderer classes that you could experiment with?
Edit
I created an MKTileOverlay and added it to my mapView to successfully remove the built-in map images:
let tileOverlay = MKTileOverlay(urlTemplate: "")
tileOverlay.canReplaceMapContent = true
mapView.addOverlays([tileOverlay])

OL3:How to judge a point feature in a specific vector source?

In my website builded with ol3, I have two or more vector layers with different sources in my map, i want to click features in a specific source and show some popup. My way is adding a single click event on my map, and using source.getFeaturesAtCoordinate(evt.coordinate) but always get empty results [].What can i do in this situation?
For points, you would need to be extremely lucky to hit the exact coordinate. You need to consider the rendered size of your points, and for that you'd better use ol.Map#forEachFeatureAtPixel(). It works on the layer, not the source:
map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
// get the source
source = layer.getSource();
// do something with the feature
});

Disable interim tiles for tile layer

When creating a map like this:
var map = new ol.Map({
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true
})
OpenLayers 3 uses interim tiles (i.e., previously loaded lower resolution tiles) when zooming and panning until it has finished loading the new tiles.
The interim tiles are placed behind the real tiles. Which is very clever, and is great for opaque layers, but much not so great for mostly transparent layers.
We currently have a layer which consists of just a few lines, only a few pixels think. Slightly panning the map makes these into huge blobs, causes a lot of flicker.
Is there a way to disable creating of these interim tiles, just for a specific layer? It would be disappointing if I'd need to disable both loadTilesWhile* properties just because of a single layer.
For an example, see: http://imgur.com/RbtmkpT
The left is normal (the red line is mine), right is after panning slightly.
This is with cacheSize 0 on the source and useInterimTilesOnError false.
Update:
OpenLayers 3.12 behaves differently. In that version, only unloaded tiles are blurry (which is to be expected), but already loaded tiles are left alone. Starting from 3.13 or 3.14, this behavior changed.
See my pull request in the OpenLayers GitHub repository for a solution / workaround:
https://github.com/openlayers/ol3/issues/5251#issuecomment-212322292

Extent bounds not respected on zoom

I came across a strange ol3 behaviour using the extent property of the ol.View to restrict the map navigation bounds.
To reproduce the error you should create a Map with a limited extent of the ol.View, like this..
var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View({
center: [-10997148, 4569099],
extent: [-13884991, 2870341, -7455066, 6338219]
})
});
Here an example with a modified version of the "WMS custom tile grid 512x256" example on jsfiddle [ http://jsfiddle.net/dpynhg67/1/ ]
The extent is limited to the US, follow this steps to reproduce the bug:
Zoom out to see also the europe
Position the pointer somewhere in europe and zoom in with mouse wheel (you will be able to zoom outside the extent)
As soon you try to pan, the view is moved to the extent configured in the View
Is this the wanted behaviour of the map?
Do you have any suggestion on how to force the View to the extent?
Because as I remember OL2 behaved differently, while zooming the map was also panned to respect the extent.
The issue you observed should be fixed now. The first release with the fix will be v3.21.0. The related ticket with links to the pull requests that fixed the bug is #5824.

Draw a grid onto an MKMapView

I'd like to draw a grid into my map, that represents the size of a tile at a certain zoom level. So for example I'd like to have a grid on my mapview that shows the outline of a zoom level 10 tile. So the outline of where this tile would be. No matter if the mapview itself is at zoom level 5 or 15, it should display the outline of where that tile would be placed.
The problem I have is how to calculate the proper rect that represents each visible "tile".
Any help is sooo much appreciated!!!
Or maybe the answer to following question would help:
How can I convert a MKMapRect to a MKTileOverlayPath?
I find that MapKit is way too limited when you want to start doing more and more with maps.
I would reccomend using Google Maps SDK for iOS: https://developers.google.com/maps/documentation/ios/start
and then using GMSTileLayer for the tiles:
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer
In the long run, replacing MapKit with Google maps gives you far more features and options and has better geolocation and reverse geolocation than Apple
You can also look at Mapbox. Between using TileMill to create a grid layer by setting the Map background to a pattern image, you could then only export zoom level 10 and either host it on Mapbox or export it to MBTiles format (SQLite-based). Then one of the Mapbox mobile toolkits could serve the tiles out as an overlay on your map.

Resources