So for 2 points:
O-O
for 3 poins:
O
/ \
O O
etc.
For example I have 2 points with the same location. They overlap. I want to offset those markers and connect them with lines like in the image below:
Here I've found something but don't know if it applies here how to customise cluster icon in mapbox-gl?
I found something similar for carto https://carto.com/blog/stacking-chips-a-map-hack/
#rofrol, basically you can use a technique called "Spiderifier" to do it.
Here is the library for using in all framework
https://www.npmjs.com/package/mapboxgl-spiderifier
If you're using ReactJS, here is another solution
https://www.npmjs.com/package/react-mapbox-gl-spiderifier
Related
I'm planning a climbing trip and I wanted to retrieve the climbing locations from a leaflet map.
I thought I could use chromedriver and selenium to get the information I wanted but I'm having difficulty scanning through all markers since I can't understand where all the informations are stored.
Could someone guide me through how I could get the information? (also without using selenium)
The map in question is: https://www.climbingsardinia.com/topos/maps/
Thank you in advance.
in that page you will see a global variable called cttm_markers, it contains all markers informations and relative coordinates.
For example, cttm_markers[0][[0].additionalData.title evaluates "M.te Arci – Trebina Longa".Further, cttm_markers[0][[0]._latlng is an object {lat,lng} that contains coordinates.
Try to open console and paste this: JSON.stringify(cttm_markers[0].map(c=>({title:c.additionalData.title,latlng:c._latlng}))), it will print a json.
One way to do it is to get some information on one of the markers and use this to search the request reponses made by the page (you can do this in the debug tools, usually opened with F12). One of the markers for example reveals the location "Grighini". The base request redirects to (in my case) https://www.climbingsardinia.com/topos/maps/?doing_wp_cron=1651158093.0027918815612792968750
Searching the response, reveals that in line 1908 there's the string "Grighini". This line contains a serialized JSON array, containing the markers.
I am using one simulator and wanted to add my own maps. So I looked into this website https://mygeodata.cloud/ which can provide me with the wkt files of maps.
The problem is I am not able to get these to work, can someone provide some details on how to add a town's map with maybe bus routes etc to ONE Simulator?
The error I'm getting is "SimMap is not fully connected. Only 1057 out of 1113 map nodes can be reached from Nt2#(-1.15,52.95). E.g. Nt2#(-1.14,52.95) can't be reached"
The default roads.wtk files have linestrings like this
LINESTRING (2551683.6644129306 6674375.029443317, 2551528.069902012
6674337.650863852)
While my linestrings of Nottingham,England are this
LINESTRING (-1.1525824 52.9518235,-1.1524917 52.9517354,-1.1519975 >
52.9511418,-1.1517313 52.9508255)
It seems that your input map has around 50 nodes that can not be reached from other map nodes. The ONE Simulator needs to have the map fully connected (i.e., all nodes need to be reachable). Check out the map source (e.g., using OpenJUMP) and look for nodes or map segments that are not connected to each other and delete them or connect them with new line segments. The error message gives you a hint where to look at.
For an example on how to add bus routes, check out the Helsinki map and the tram/bus route files: https://github.com/akeranen/the-one/tree/master/data
that is because there is a broken node there should be a check again for the existing map input because some moves do not want any broken lines there can make messages from open strapmaps then edit using open jump
A lot of the times the Google documentation is incomplete and is missing things like libraries required to import. How do I view a more comprehensive example?
Example: https://cloud.google.com/vision/docs/detecting-faces#vision-face-detection-python
def highlight_faces(image, faces, output_filename):
"""Draws a polygon around the faces, then saves to output_filename.
Args:
image: a file containing the image with the faces.
faces: a list of faces found in the file. This should be in the format
returned by the Vision API.
output_filename: the name of the image file to be created, where the
faces have polygons drawn around them.
"""
im = Image.open(image)
draw = ImageDraw.Draw(im)
for face in faces:
box = [(vertex.x, vertex.y)
for vertex in face.bounding_poly.vertices]
draw.line(box + [box[0]], width=5, fill='#00ff00')
im.save(output_filename)
Missing the PIL import
On many of Google's code examples, there will be a VIEW ON GITHUB button that will take you to a complete working example rather than a snippet. Very useful for finding necessary library imports or just going straight to more code.
When that is missing, sometimes there is a link to the file like this firebase example linking to index.js:
I've been trying to get a list of co-ordinates in a route from point A to B using OSRM with the following request:
GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
However, on opening the url, i find the 'via_points' tag containing only two co-ordinates. Surely, that can't be the entire route? Anything I'm missing here? Is there any other way of generating the list of route co-ordinates with OSRM? Thanks
The route is contained in the route_geometry object. It is an encoded polyline. If you don't want to uncompress it yourself you can disable compression via compression=false:
http://router.project-osrm.org/viaroute?compression=false&hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
Not sure what the via_points contains. OSRM's documentation seems to be outdated. Maybe they are just your start and end points snapped to the nearest road or something similar.
I would like to get the distance between 2 markers but not as a direct line, more as a real path like it goes in this plugin -
https://github.com/perliedman/leaflet-routing-machine
I didn't find anything about using this plugin in the directive: angular-leaflet-directive,
if someone can guide how to make it done, it would be very appreciated.
thanks!
I am not sure if you specifically want to use leaflet routing machine to get distances... but if you do, maybe this info can get you started:
Set up a route on your map based on this example by the leaflet routing machine author:
https://www.liedman.net/leaflet-routing-machine/tutorials/interaction/
If you look at that example, there is an array called routes. Each route has some basic statistics associated with it, generated by OSRM. You can pull them by calling for example:
routes[0].summary.totalDistance
or
routes[0].summary.totalTime
Then you can do whatever you want with them. If you dig through the code on GitHub you can see more about how the data are moved around within the plugin and why the array is arranged that way:
https://unpkg.com/leaflet-routing-machine#3.2.12/dist/leaflet-routing-machine.js