I would like to get the street name from a clic on an OSM map. The user displais the map of a town, zoom in and clic on a street then the application displays the street name.
Is it possible ?
For example, could it be achieved by using a rule of three with the GPS coordinates of the corners and the position of the clic in pixels ?
Bernard
It can be done in 2 steps.
Find the geocoordinate of the click. With openlayers you can get the coordinates of a feature (see ol documentation) or even any click (see question here).
Find the street/location name from the coordinates: This is called reverse-geocoding. There are services to do this, e.g. google or better something free, such as positionstack.
Related
I'm new to OSM and would like to know if my approach for finding the next intersection ahead is possible when doing it offline.
The goal is to get the coordinates (latitude/longitude) of the next intersection on the street I'm currently driving on. For that I have my actual position (lat/lon coordinates) and heading (w.r.t. the north-pole) at disposition.
My current approach right now is to first use my coordinates for getting the name of the street/way/trace in which I am driving; then use that name for knowing which are the next intersections on that street (to both sides); and then use the heading for knowing which direction is the one I should pay attention to.
Once I have the intersection, I would get its coordinates and continue with the program.
My questions are then, is it possible to do all of that offline, i.e. with a .osm file (or similar)?
And, do you know a better approach for getting the coordinates of the next intersection ahead?
Thanks a lot in advance!
PS. I was able to get the name of the street by using nominatim and to get all the intersections of a street by using Overpass turbo, but this solutions would need internet; or is there a way of using them offline?
I've been tasked with creating a Google Earth Web link programmatically when given coordinates. I have the street address as well, where I'd ideally like to drop a pin.
For example, I can get a link to the white house using its lat/lon at a distance of 150 meters like this:
https://earth.google.com/web/#38.8976633,-77.0365739,150d
If I search using the google earth web app I can generate a link with a pin, where a few of the parameters in the link change slightly:
https://earth.google.com/web/#38.8976763,-77.0365298,18.0497095a,800.41606338d,35y,0h,45t,0r/data=ChIaEAoIL20vMDgxc3EYAiABKAIoAg
Am I able to dynamically generate the data element, or whichever element creates the pin, at my desired location? I've also had trouble finding the correct distance d and elevation a parameters in my links.
As you found, you can generate links to specific views in the Google Earth web client by adding the correct parameters to the URL, including the latitude, longitude and altitude (a) of the view target, and the distance (d) of the camera from that target. Note that altitude and distance are both in meters, and altitude is above sea level, not above ground elevation. If you look at the a and d parameters that Earth puts in the URL as you fly around, often altitude will be the terrain (or builing-top) elevation at the target lat/lon, and the distance will be how far the camera is from that altitude. The other available parameters include heading (h) and roll (r).
So long as your tilt (t) remains zero, then altitude and distance should be interchangeable, or if both are >0, then they will be summed together for the final camera height above sea level. But if you add a tilt (zero degrees is looking straight down), then the altitude determines the elevation of the view target (above the lat & lon location), and the distance determines how far the camera is from that point. If you make d=0, then altitude will define both the view target and camera height above sea level. If you make a=0, then the distance will be from the lat,lon at sea level (even if that's underground).
Unfortunately there's no way to manually construct the data parameter, as it can contain many different things. To do that right would require an API, which Earth for Web currently does not provide. Hopefully that kind of functionality will come after Earth finishes its work to become cross-browser compatible via Web Assembly. Until then, there's not a way to add a point the map via just a URL.
I have a leaflet map with several thousand markers that are clustered. I show an icon for the users current location on the map and I need to show the distance to the nearest marker in all four directions. So for example, North:100M, South:1KM, East:.... and so on.
I dont see an inbuilt way in leaflet to do this. Any ideas on I can go about accomplishing this ?
Is there any way to adjust the bounds of the map so that the right-edge of Russia doesn't appear over to the left? You can see in the image I have a MultiPolygon area overlaying Russia but the map and the overlay are split. I'd like that tiny piece of the country to be on the right if possible!
Edge of Russia on the wrong side of the map:
A workaround I can think of is using the maxBounds property, where you would shift the default bounds slightly to the right, along with minZoom: 1. This won't prevent the user from seeing the world several times for a short time if zoomed out far / panning outside, as it says there:
... bouncing the user back when he tries to pan outside the view
var map = L.map('map',{
maxBounds:[ [-90, -160], [90, 200] ],
minZoom: 1
}).setView([66.058, 189.459], 4);
Demo
Welcome to SO!
If your multi polygon is the blueish area, then I am afraid you have to refactor your data in order to achieve what you want (shifting the left area onto the right, as if it were stitched back to Russia main land).
Your data (probably GeoJSON?) contains a separate polygon which longitudes are in the [-180, -120] range. Leaflet has no choice but to display it on the left of your map, independently from the noWrap option.
So you would need to dig into your data, and add 360 degrees longitude to every node of this polygon, so that they now sit in the range [180, 300].
Or somehow introduce a "detection" in your code that would perform the longitude addition automatically for shapes which bounds and/or center are far away (let's say in the [-180, -120] longitude range). Leaflet does not perform that operation automatically out-of-the-box.
Note: the noWrap option is for your Tile Layer not to load tiles outside that "central" world (in order to avoid showing multiple copies of the world). But in your case, you want to show a part of Russia / Siberia on an "adjacent copy of the world", so you might want to remove that option, or you will have your polygon not sitting over any basemap.
Seems like the US County map for Highmaps is missing New York and DC (among others)
http://www.highcharts.com/maps/demo/us-counties
Is there a complete and correct geojson US-county map available?
There is a Free API to obtain US County in GeoJson format:
Example query:
https://vanitysoft-boundaries-io-v1.p.mashape.com/reaperfire/rest/v1/public/boundary?and=true&county=Washington+County&state=MD
please note that some zipcodes do not fall within a county.
The good news is that the GeoJSON does include New York and DC (and I'm fairly certain all counties in the US). What you are experiencing are two separate issues.
For DC, it is already drawn on the map, but the problem is simply that it has no data to display from the source. Therefor it appears as though it is just a hole in the map. The path for DC is drawn and very much visible (just not lively colored). Change the fill color to black and you'll see it.
For New York county it is also drawn on the map, but unfortunately it is only 1 pixel wide and doesn't show up at all visually even when zoomed. This could be fixed by altering the geometry of the GeoJSON data for that county specifically. To see that it is there you could give it an id in the data and use Point.zoomTo to see where it would've been (if visible).
I'm not certain what defines "correct", but you're not going to get a GeoJSON on a centimeter-scale of correctness, so it comes down to how many points you want to use for the geometry of each element.
If you look at the drilldown map it is even more coarse when displaying the overall map, but when zooming in it shows New York county perfectly. Perhaps you could somehow combine or utilize the different levels of granularity of the different GeoJSON files.