I have a set of information as a csv-file that I want to bind in several pop-ups using Leaflet.js. For that I need to collect hundereds of city-coordinates mentioned in the csv-file.
During my research I found OSM Boundaries what makes collecting geojson-data quite easy. But the problem with OSM boundaries is that it only contains geometry as MultiPolygons.
In my case I'm searching for a single pair LatLng coordinates like from the citycenter or so.
geojson.io is another simple tool to collect geojson. I can search for the cities but need to set a marker on the map by myself. That seems quite uncomfortable to me.
I know that Open Street Map offers all the information I need, I just don't no how to export/collect them properly.
Thanks for any kind of help!
You sound to be looking for geocoding functionality, i.e. finding the lat-lng coordinates of your places by city name.
Please have a look at Leaflet geocoding plugins. With most of them, you can use them programmatically, instead of manually entering the city name. Check out each one API.
Note that your result may still need some manual clean up, as geocoding often gives you several matching places.
I have a set of information as a csv-file that I want to bind in several pop-ups using Leaflet.js.
You don't need GeoJSON at all. Simply load the CSV as a text string, parse it, iterate through the rows, and instantiate Leaflet markers as needed.
Related
My application should allow users to store events and their locations and then perform search on them - so I need those locations in my database with their names and latitudes/longitudes. Google API doesnt allow storing anything else but place IDs so I have to find something else that can autocomplete/suggest places on UI and allow storing it my database.
Does anyone know such a good service?
You can simply add your points in your DB based on each point Lat & Long values. So when user is searching somewhere you have his current location(Lat-Long), Therefore you can search in your DB and get the distance of each saved point with current location and retrieve the results you want to show (i.e in JSON format).
In client-side use some auto-complete jquery library to show the nearby places and somethings like that (with additional information).
Google Map API has a service that you can show some custom marker on the map with your custom configuration like marker icon, description and etc. You can show your additional information in description as HTML format.
You can see some example here:
Customizing a Google Map: Custom Markers
Hope these tips would be helpfull. Regards.
Suddenly I've found an answer that helps me:
https://productforums.google.com/forum/#!topic/maps/hNc1OOU6Zm8
So I can use some Google's data under some conditions.
What I need is the following.
Whenever I add any instance of object in my website, I need the server to add the location of the object to my own map either in Google maps or Bing maps (Bing maps docs are more clear therefore I'm going to use Bing).
Later, whenever I view the object in my site, the map should point to the location of the object and other my map objects in the same map.
How can this be achieved? Do I need to hold all the coordinates and object descriptions in my server, or somehow it is saved in the google or bing.
I went through the docs, but couldn't find any information I need.
You need to store them on your server and load them into the map on your webpage. There are ways with both google (fusion tables) and bing (spatial data services) of storing them with the provider but if you are already storing a copy for your website you are better off keeping them there for the map rather than maintaining two copies.
I'm not sure how technical you are but this best architecture approach is this:
1) Write a database query that finds objects to show on your map, ideally filtered by whatever the user can use to filter objects elsewhere on your site. Add to this query a filter by geographical bounding box (the range of latitude and longitude that can be seen on your map at any one point). The bounding box filter is just a simple sql BETWEEN clause but will mean you dont have to load every single object on to the map.
2) write a "webservice" that uses the database query in 1) and turns the results into JSON. This approach will lead to a much cleaner seperation between your mapping code in javascript and your server side code in the webservice.
3) Write your mapping frontend in Bing using javascript and use something like Jquery to read data from the webservice as the map is moved around re-load data that know should be shown on the new map view. As the data will be in JSON its much easier as JSON will just give you javascript versions of your objects
I want to create a web app that lets me create, store and display my travels. Something similar to this service here actually.
The basic structure/ideas:
create my trips by the following options
load a gpx
create a polyline (e.g. flight path)
create a route using google directions
Each trip consists of one ore several "stages" or "legs" that each can be creates like above
store the routes so that i can display them on a google map or edit them (draggable) later
So one map would then contain several "trips" that look like this
I have already read a lot about this matter and I think I should be able to handle the part about creating the routes, however when it comes to storing them I'm not sure if I have understood what's possible and how to do it.
My questions:
Storing: I was thinking to either convert each trip once it is complete to their own XML file containing all the required information such as waypoints and stages. Those file would be stored on my webspace and can then be parsed to display the trips at any time
I see a problem however when creating a leg using google directions: how can I store/retrieve such a leg and conserve the directions informations? It's rather easy as long as I don't change the route by dragging wayoints (I coudl simply store the start and end points and create it on the fly) however I would like to be able to edit them later, again by dragging the line. Would it be possible to extract all the additionally inserted waypoints to recreate the route later by using not only the start and end point but also those additional points (i.e. will google show me the same variation of the route?)
Is there any aspect that is against the terms of gmaps?
I could also use a mySQL database to store the information, is this the better approach?
BTW I am new to the whole gMaps API programming. My system is php based.
I would recommend you a mysql database to store the information. A directions is only a bunch of lat-long pairs, travel time, and polyon points. Usually I store it in a JS array but you can also use a Json or JS objects. I think you can serialize the array and store it in database. I would use xml only for configuration or formated output with xlst. The idea is also to store the lat-lng as points and use a spatial index on it to get faster search.
Ive come across this website, http://gmaps.kaeding.name/, which allows you to plot multiple locations on a static google map.
My question is how is this done..? I'm not trying to copy what he's done, just understand as Im trying to achieve something similar.
In the blog it says "You enter as many addresses as you want, one per line. Then the script sends those strings through geocoder.us to get latitude and longitude"
Would this be a Visual Basic script...? Or am I barking completely up the wrong tree...?
sorry to be so vague but not sure where to start
The form posts to cgi-bin/map.cgi on the server, so any attempt to work out the implementation would be pure guesswork. There are implementations of this functionality in pure client-side Javascript, if you care to Google them, such as this one:
http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/
You don't need to rely on geocoding per se, as the Google Static Maps API allows you to provide addresses for locations plotted on a static map as markers.
From the docs:
Each marker descriptor must contain a set of one or more locations
defining where to place the marker on the map. These locations may be
either specified as latitude/longitude values or as addresses. These
locations are separated using the pipe character (|).
The Static Maps API includes features that allow you to overlay markers, lines, and polygons. So to implement something similar, you'd simply collect the form field values and then submit the request to the API (either via server-side or client-side [AJAX] code).
Is there any way to get the geo coordinates for a driving direction from Google Maps API?
if we use URL to show the driving direction with source and destination address we'll get the map and route as an webpage, instead of that I like to get the co-ordinates and details in some XML like format.
Sure, see the docs. You make a GDirections object (without a div AND without a map so nothing will be displayed by default and you'll handle all the displaying), and call its load method, specifying getPolyline and getSteps as both true (so you'll get the polyline and the textual directions despite the lack of div and map).
The GDirections' object load event fires when the results are ready. Then you use getPolyline, getNumRoutes, and getRoute methods on the object to retrieve results.
As a full reference, also check this (both GDirections and GDirectionsOptions)...!
The Google API documentation has a section on XML requests and parsing. It's quite detailed, many options available.
Hai all,
Finally i got the solution, google also provides the driving directions in JSON format, we can parse the JSON data and that will give all the details including coordinates, name, description, distance and approximate time
example:
http://maps.google.com/maps/nav?key=YOUR-MAP-KEY&output=json&q=from:sourceAddress to: destinationAddress
Thank you all for the support