In my project I am using leaflet.
I am getting addresses from my database (in array with php) and want to show latitude and longitude associated to each address.
I know there is a great geocoder developed for Leaflet:
https://github.com/smeijer/L.GeoSearch,
but I don't konw how to use it for my purpose.
Can anyone help me on this?
Any help would be gratly appreciated.
I would advise on using http://open.mapquestapi.com/nominatim/
There you will have an example of how to create a query and you will see the look of the response you will get. The are basic simple search examples and the look of the code that runs it. Inside of the response you will have the lat/lon pair so you can use that to draw the marker on your map in Leaflet.js
Related
please be kind, I'm new to coding. Can I ask that you explain things as simply as you can for me. I have an sql table that contains building information inc. Longitude and latitude(over 5 thousand buildings). I need to pull this data into visual studio and then pass it to my Google maps api to drop markers according to the lat and long. There are tutorials using php but we don't use php. I really need and appreciate any help you can give me. I have created a json file from sql and copied it into a json file in VS. So the bones are there, I just need help putting it together.
Thank you
Mike.
Create a stored procedure. which takes buildingId as an input parameter. and select the latitude and longitude in SP. you can pass these values to the API
You can also check this thread. Maybe it would help you with jQuery and Javascript.
Retrieving latitude and longitude from mysql, passing it to google maps api
I don't have latitude and longitude coordinates to set view on leaflet js library. I had an array of objects which contains city and state, country as properties.Now i want to set the markers on the map using leaflet js for this array. What could be the better way to do this?
You need something called a geocoder, that can help you look up the latitude and longitude given the name of a geographic place.
Geocoders are typically quite complicated pieces of software that you run on a server. Fortunately, there are several available that you can use from an HTTP interface, as well as Leaflet plugins to communicate with them.
On Leaflets plugin page (http://leafletjs.com/plugins.html), under the section Geocoding (address lookup), you can find several plugins that might interest you.
For example, you can use Leaflet Control Geocoder (disclaimer: I'm the author of this plugin) that you can either add to the map to let a user search directly, or you can use classes that communicate with the geocoding services directly, to lookup geo coordinates from any string - see for example the class L.Control.Geocoder.Nominatim to use OpenStreetMap's Nominatim geocoding service.
I know how to set up geocode and pull the user's lat and long coordinates. However how do I turn this into a state name or code ie(DE, MO FL). I've looked at using Google's reverse geocode, but am unable to get an API code. Any other way to go about this?
As the comments suggest the only way to achieve this is via reverse GeoCoding.
Here's a link to the API docs for reverse GeoCoding:
https://developers.google.com/maps/documentation/geocoding/
And an anchored link to the outputs, clearly showing the state:
https://developers.google.com/maps/documentation/geocoding/#GeocodingResponses
I've found some of the Google API docs somewhat confusing so I'd suggest searching for a worked example where someone has done something similar.
I have readed the API for elevation for Google Maps and what I can understands I must have the map visible to get the elevation for a point (coordinates). But almost nothing is impossible with JavaScript so I wonder now, is it possible to get the elevation from a point without viewing the map?
Thanks in advance.
Do you know what the co-ordinates are for the point? If so, the API for elevation will return the elevation, in both JSON and XML formats. I use the following URL (albeit in PHP, it should work the same for Javascript):
http://maps.googleapis.com/maps/api/elevation/xml?sensor=false&locations=1.111,1.111.
You'll need to parse the results in JS. Switch XML out for JSON in the URL to change the result type.
Edit: If you use this service, you need to use it in conjunction with a Google Map as per their terms and conditions.
I am working now on little project.
In one view i am returning data for google maps API (longitudes and latitudes).
Under the map I have to implement few buttons to add point of interests on the map in this location which is actually showed.
There could be some buttons/types of POI like schools, banks, atms etc.
So, let's go back. When I put all my markers on map how to add there points of interests?
I would like to get below data for them:
longitude (needed for show)
latitude
type
title
description
I know, that there is google local ajax search api, but I am not sure if it is correct way to do.
I know how to find this data using google maps interface, for example:
Example Map
http://maps.google.pl/maps?f=q&source=s_q&hl=pl&geocode=&q=category:%22Banks+%26+Financial+Institutions%22&sll=51.510202,-0.12144&sspn=0.01859,0.05549&ie=UTF8&cd=1&ei=N4hUS7ynEc7AjAeWtNm4CA&radius=1.19&rq=1&ev=zi&hq=category:%22Banks+%26+Financial+Institutions%22&hnear=&z=15
but how to do this using API?
Thanks.
The Google Local Search API can be used to obtain a small number of such points at a time, as in this example. Or you could just add the Googlebar to your Maps AVI v2 map.
Access to large numbers of such points at once is not available from Google, and is generally not available for free.
In addition to Google, there are other data providers you can use. For example, the API at http://compass.webservius.com allows you to retrieve data on more than 16 million businesses in the US (including name, lat/long, business type / industry code, etc).
The Google API is a Javascript API.
If I understand you correctly, you want to add markers on a Google Map using the Google Maps API.
The documentation suggests that either you hardcode your Markers or create one by creating a Marker Manager.
I have never used Google Maps API but if you want more info, visit the documentation here.
Good luck!