I was asked to see if I could using leaflet draw a circle and as I'm drawing it show what the current expanding radius is. Either as a tooltip or write it to a page label. I noticed the circle option has a showRadius option but can you capture this value as your drawing the circle?
Kind of like the measure tool that uses the drawing plugin can show your distance as you move the mouse.
This way the user can see how big their circle is as they are drawing it.
Any ideas, examples, hints?
Leaflet.draw plugin does that.
Check out this demo
However, it shows radius only when you create a circle. Unfortunately, not when you edit it.
Related
I have a triangle polygon filled with color and low opacity. That was no problem so far.
What I'm trying to achieve looks like this (without points and lines). It is basically triangle polygon with fill color but opacity smoothly lowering from one of the triangle apexes.
Is there any way to achieve this with mapbox? Thanks!
There is no easy, built in way to do this with Mapbox GL JS.
The best way I can think of is to create a Marker (an HTML object anchored at a specific lat/lng) to draw the shape. You will have to do some maths to translate the coordinates of the triangle's vertices into screen coordinates. You will also have to update the calculations if the viewport zooms or rotates.
I am having trouble creating a battle royal zone in unity. I want it to be translucent and cover the map with a masked circle in the middle. However, I dont know if there is any way to control the radius of this mask which is something I need to do regularly. Does anyone know how to achive these results?
It should look like the the map view from Fortnite BR.(https://assets.rockpapershotgun.com/images/2019/01/fortnite-small-storm-690x388.jpg/RPSS/resize/690x-1/format/jpg/)
There are a few ways to achieve this effect.
The first and easiest is using the built in Mask, if you are using UI to render the minimap. You can also create a custom UI mesh, as described here for example.
The last option is a (custom) shader. You can download the built-in shaders here and copy over the UI one. Then you have to add your own logic to the fragment shader, something that looks for the Length of the distance of the current UV coordinates and the circle, and if thats smaller than the radius it must be inside. In that case, either clip or set the alpha to 0.
I have developed a map using leaflet and leaflet.Markercluster. My problem is, that when the circle, at full zoom, is too near the original circle, it is not clickable.
In the image, you can see the pop-up that is displayed when you click on a circle. However, when you click on the red circle, no pop-up displays. Firstly, let me emphasise, that the red circle is actually the same as the other circles, I have just coloured red in this image, so I can refer to it. Based on this example, and other examples I have, the problem is when the circle is covered by the original circle (barely visible as an orange shade in the centre).
Is there a way to fix this?
Thanks
This is a known issue of Leaflet.markercluster plugin when you use CircleMarkers and they are spiderfied: see also this post on GIS Stack Exchange https://gis.stackexchange.com/questions/259376/reading-attribute-popup-information-from-cluster-presented-points-in-the-map-gen/259538?noredirect=1
This should normally have been fixed by default since 2018 (PR #846, included since v1.3.0), which version of Leaflet.markercluster are you using?
If you still have an issue, please raise an issue on the plugin repo, and provide a reproduction sample.
In the meantime, you can also use the old trick of increasing spiderfyDistanceMultiplier option to more than 1, so that the spiderfication is bigger, and the innermost Circle Marker extends beyond the Cluster icon.
I am creating a MapBox project with a geoJson vector layer. I have been using the following example as my guide.
https://www.mapbox.com/blog/neighborhood-mapping-with-dynamic-vector-data-layers/
When I hover over any geoJson feature the stroke is changed to 2 pixels. However the stroke gets clipped by the neighboring features sometimes. I believe this has something to do with how the different features are stacked. So if I hover on a feature which is stacked near the bottom the neighboring features are covering that stroke.
Here is an example...
http://www.vandam.com/chpc/inconsistent_stroke.jpg
Is their a way to set the stroke to be inside of the polygon or a way to bring a feature to the top of the stack when hovering?
Thanks for any help!
By adding the function
layer.bringtoFront();
after setting the hover styling your polygons will come to front.
I am adding some functionality to an iPhone app, and could use some help in picking the fastest / most efficient / best practice approach for solving this problem:
At the upper-half of my screen, I have speech bubbles (think comic book) that are UIImageViews translating across the screen (dynamic x & y position). It is a UIImageView because there is an image as the background of the speech bubble.
Each speech bubble has a matching image moving around the bottom of the screen (elsewhere in the layer tree)
I would like to draw a tail (that triangle bit from a speech bubble) so the point of the triangle is tracking the lower image, with the base of the triangle being attached to the bottom of the upper UIImageView. (technically the base doesn't have to be butted against, it can overlap as long as I can match the color of my background image to the triangle).
I have already done all the tracking & drawn a line with CGContextStrokePath methods, and now I am stuck on how to replace the line with a triangle.
I have looked at drawing a triangle in Quartz and filling it. My concern is the speech bubbles are repositioned every 1/10th of a second, and it looks like drawing just the line used for proof of concept had a pretty severe performance / visual smoothness impact.
One idea I have is to do the trigonometry myself, and stretch & rotate an image of a triangle to connect each of these speech bubbles with the lower spot. Something is telling me there is a more efficient / more elegant solution, but I am not able to see it looking through the documentation. Any help on how you have or would approach this issue is appreciated. Thanks.
If the speech bubbles are fixed in size, just use a static UIImage. Set the image view's layer.position property at the point of the triangle. Then you can use view animation to move the bubbles around.
If you need the speech bubbles to be different sizes, I'd create a resizeable image using resizableImageWithCapInsets. Then I'd do the same as above to position it.
If there was something special about the speech bubble that I could't achieve with either a static image or a resizable image, I'd probably create a custom CA Layer or layers to get the effect I wanted (Like a gradient layer with a shape layer as it's mask layer)