Leaflet 6 upgrading from version 5.x - leaflet

This is the result after the upgrade http://jsfiddle.net/tYbcu/1/
Everything seem to be in a small square in the middle.
This is the code before http://jsfiddle.net/cliff/CRRGC/
What's happening here?
Everything I set is almost the same
map = L.map("map", {
minZoom: 0,
maxZoom: 7,
crs: L.CRS.Simple
}).setView([0, 0], 0);

Try to set the maxZoom to 6
map = L.map("map", {
minZoom: 0,
maxZoom: 6,
crs: L.CRS.Simple
}).setView([0, 0], 0);

Related

Visualization failed when display two polygon in the same time

I want to display two polygons in one renderer. And the result is:
The green and red color indicates two polygons.
However, when I rotate it, some part of green color disappear:
My environment is:
win 10
python 3.7.13
vtk: 9.2.4
I can 100% reproduce this phenomenon, and the code to reproduce my problem is:
import vtkmodules.all as vtk
def buildPolygon(points):
polydata = vtk.vtkPolyData()
vps = vtk.vtkPoints()
polygon = vtk.vtkPolygon()
polygon.GetPointIds().SetNumberOfIds(len(points))
for i in range(len(points)):
vps.InsertNextPoint(points[i][0], points[i][1], points[i][2])
polygon.GetPointIds().SetId(i, i)
polygons = vtk.vtkCellArray()
polygons.InsertNextCell(polygon)
polydata.SetPoints(vps)
polydata.SetPolys(polygons)
return polydata
polydata1 = buildPolygon([
[0, 0, 0],
[10, 0, 0],
[10, 10, 0],
[0, 10, 0]
])
map1 = vtk.vtkPolyDataMapper()
map1.SetInputData(polydata1)
actor1 = vtk.vtkActor()
actor1.SetMapper(map1)
actor1.GetProperty().SetColor(1, 0, 0)
polydata2 = buildPolygon([
[0, 0, 0],
[5, 0, 0],
[5, 5, 0],
[0, 5, 0]
])
map2 = vtk.vtkPolyDataMapper()
map2.SetInputData(polydata2)
actor2 = vtk.vtkActor()
actor2.SetMapper(map2)
actor2.GetProperty().SetColor(0, 1, 0)
render = vtk.vtkRenderer()
render.AddActor(actor1)
render.AddActor(actor2)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()
As they lie exactly on the same plane z=0 there is no way to know which should be drawn on top of the other. Just add a small tolerance:
polydata2 = buildPolygon([
[0, 0, 0.001],
[5, 0, 0.001],
[5, 5, 0.001],
[0, 5, 0.001]
])

Assigning real coordinates to Image map in Leaflet

I am working on a floor map which is an Image, where I want to assign real coordinates to the map, So when I click anywhere on map I should get the real coordinates. I have completed almost everything but don't know how can I assign real coordinates to map.
I am new to Leaflet.
var map = L.map('image-map', {
minZoom: 1,
maxZoom: 4,
center: [0, 0],
zoom: 1,
crs: L.CRS.Simple
});
// dimensions of the image
var w = 2000,
h = 1500,
url = 'http://kempe.net/images/image-of-a-floor.jpg';
// calculate the edges of the image, in coordinate space
var southWest = map.unproject([0, h], map.getMaxZoom()-1);
var northEast = map.unproject([w, 0], map.getMaxZoom()-1);
var bounds = new L.LatLngBounds(southWest, northEast);
// add the image overlay,
// so that it covers the entire map
L.imageOverlay(url, bounds).addTo(map);
Simply do not use L.CRS.Simple and specify "real coordinates" bounds for your Image Overlay. You can just drop all the map.unproject thing.
L.imageOverlay(url, [
[latCornerA, lngCornerA],
[latCornerB, lngCornerB]
]).addTo(map);
Then everything else will use the default CRS and mouse events will generate an event.latlng with corresponding coordinates.

Mapbox - Style property according to zoom and property

I'd like to style points on my map as follows:
'circle-radius': {
property: 'pixelRadius',
stops: [
[0, 0],
[20, 'pixelRadius'],
],
base: 2,
}
The use case is similar to Drawing a circle with the radius in miles/meters with Mapbox GL JS
Except that in my properties map I have computed the pixel radius so that each point in the FeatureCollection has its own radius.
Can this be done? All of the examples Ive seen with stops have a hard coded value for the 2nd array element.
Try this:
'circle-radius': [
"interpolate",
["exponential", 2],
["zoom"],
0, 0,
20, ['get', 'pixelRadius']
],
So here it is using expression (https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-get) instead of function.

Polygons transparency

I need to bind texture on 2 crossed polygons and make them(polygons) invisible (with alpha=0). But textures are transparent with polygons.
Is is possible to make transparent only polygons without their textures?
By this way i bind textute
Gl.glEnable(Gl.GL_BLEND);
Gl.glEnable(Gl.GL_ALPHA_TEST);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glColor4d(255,255,255,0.1);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(1, 0); Gl.glVertex3d(2, 2, 3);
Gl.glTexCoord2f(0, 0); Gl.glVertex3d(4, 2, 3);
Gl.glTexCoord2f(0, 1); Gl.glVertex3d(4, 4, 3);
Gl.glTexCoord2f(1, 1); Gl.glVertex3d(2, 4, 3);
Gl.glEnd();
Image
I need smth like on the left part of the img.
I found the solution.
Load png!! image
GL.glBindTexture(GL.GL_TEXTURE_2D, this.texture[i]);
Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_REPLACE);
Gl.glAlphaFunc(Gl.GL_LESS, 0.2f);
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)Gl.GL_RGBA, image[i].Width, image[i].Height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
And drow object:
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
GL.glEnable(GL.GL_BLEND); // Enable Blending
GL.glDisable(GL.GL_DEPTH_TEST);
GL.glBlendFunc(Gl.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
GL.glBindTexture(GL.GL_TEXTURE_2D, texture[0]);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(1, 0); Gl.glVertex3d(2, 2, 3);
Gl.glTexCoord2f(0, 0); Gl.glVertex3d(4, 2, 3);
Gl.glTexCoord2f(0, 1); Gl.glVertex3d(4, 6, 3);
Gl.glTexCoord2f(1, 1); Gl.glVertex3d(2, 6, 3);
Gl.glEnd();
And you will get your image without any background.

Zooming out on Leaflet.js with L.CRS.Simple does not load tiles properly

I'm using Leaflet 0.7.2 to render tiles created with tileup from a large image (not a map) with the L.CRS.Simple projection.
I have tiles for zoom levels 17-20. Tiles display correctly at zoom levels 17 and 18. At 19 I see scaled tiles from zoom level 18. Zoom level 20 renders a blank map.
Map options:
{
crs: L.CRS.Simple,
center: [w / 2, h / 2],
zoom: 17,
minZoom: 18,
maxZoom: 20,
continuousWorld: true,
layers: [
L.tileLayer('tiles/{z}/t_{x}_{y}.png')
]
}
I've tried with and without continuousWorld and maxNativeZoom.
I see 404 errors for some tiles. These are outside the provided world.
Somewhat counterintuitively, maxZoom on map does not propagate to layers, so your layer is keeping the default value of 18. Just try adding maxZoom to your tileLayer as well:
var map = L.map('map', {
crs: L.CRS.Simple,
center: [w / 2, h / 2],
zoom: 17,
minZoom: 18,
maxZoom: 20,
continuousWorld: true
layers: [
L.tileLayer('tiles/{z}/t_{x}_{y}.png', {maxZoom: 20})
]
});