We have a database of addresses that we deliver to. It consists of the following data;
StreetName
NumberFrom
NumberTo
ZipcodeId (points to seperate table with zipcodes, which holds cityName)
StoreId
Would it be possible to highlight all those addrresses on a map like GoogleMaps (preferred), Bing, OpenStreetMap, etc. ?
I know how to add polylines, and have done geocoding in the past for addresses.
A possible issue with the data, is where it covers whole street they practise have been to just set the NumberTo to 9999. If i plot an address into google Earth with 'StreetName 999, City' it will place the point in the middle of the length of the street.
Also tried a random number, and it placed the marker on a building instead of on the street.
I don't know if it's different for GoogleMaps..
Update
I think that the DirectionsService in GoogleMaps API is the way to go, now i only need to figure out if and how i can use it multiple times on a map.
Success!
I was able to iterate over all the addresses, doing a DirectionsService request for each addres, from start of street to end of street. Extract the GeoPoints used by DirectionsDisplay, stored it to the database and is now able to draw Polylines on a map for each road.
I could iterate over the addresseseach time the map is shown (in-house use only). But still this would be a performance issue, and also unsure if how many request Google will handle per day. By storing it in DB i only need Google to calculate it once.
It can, but only in certain areas of the world - e.g. US
But you need to prepare your adresses - lets say in div/spans - then on onload document, you calll the API
I did this using Lat/Lng from a Garmin Edge - the difference is that you need to translate your addresses into lat/lng, before you can position these on the map canvas.
Mike
Yes you can convert the Address to a GeoPoint and then plot the GeoPoints on the Map. Start by looking here
Related
I have build employee location history tracking app in Ionic 4.
The process is as follows:
1- There is a service which fetches the current location after 5 second
2- Upload the fetched coordinates to database
But sometimes the location fetched is incorrect i.e 4-5 meters away from where the current employee is. I dont know why is this happening even though I am using accurate location fetching.
Anyway,
In admin panel, I draw the polygon on Google map from the coordinates which were saved.
As you can see the polygon and the whole track is quite weird.
Is there any way to draw the lines as we get in directions API?
Or something like trailing line drawn like this in life360 App.
I want the history locations to be drawn quite smoothly on maps instead of weird polygons line which doesnt bother the roads and paths
You can use the Directions API. Input all the points as waypoints and the response will contain an encoded polyline that will be on actual roads and look nicer than a polyline.
https://developers.google.com/maps/documentation/directions/
Background I'm a bit new to google maps/mapping sdks in general. I want to create a street by street "heat" map of an area on iOS. As an easy to understand example, let's say it will be for the purpose of mapping daily puppy sightings in a city. The data changes regularly, we need to show that certain streets have more puppy traffic than others.
Similar to the ones pictured here
https://blog.mapbox.com/spotangels-mobile-parking-maps-30db4b10aee7
And here
https://www.trulia.com/local/san-francisco-ca/type:traffic_volume_live
To do this, I would like to get a unique ID for each street block.
Something like this:
Question: How can I tell when a user entered a unique street? How can I get a unique street ID?
Related side question: If it's not possible in google maps, links to doing it in OpenStreetMap or Mapbox would be appreciated.
Places I've looked
How to get an use an unique identifier for each street in google maps api
Issue: No answer
Highlighting whole street with some maps API
Issue: Info from 2010
Google Maps: Get coordinates of a street block
Issue: No answer
Get street graph for a game using Google Maps API
Issue: Info from 2012
Map Highlight Odd/Even Side of Street
Issue: Unanswered
Display traffic data with maps
Issue: Unanswered
How to get only street/road coordinates via reverse geocoding (Google Maps API)
Streets in a radius
How to get all roads around a given location in OpenStreetMap?
Partial solution OSM
This should be doable with OSM data.
Retrieve the streets around you (e.g. using Overpass API and the around query). Determine the way you are currently driving on, then split it at each intersection node. Now you have street segments similar to your second image. The start and end node ID of each segment could be used as (temporary¹) identifier.
¹ temporary, because IDs in OSM can change eventually.
The problem I have is that I would like to highlight the whole street from beginning to the end. For example if I enter Av. Montaigne, Paris, France in Google Maps, I want the whole street to be highlighted.
It seems that Google Maps does not support this option and I would have to implement algorithm to mark the street by using polylines. However, I am not sure if there is a somewhat easy way to get information about how the street looks like, because the street could be curved so it is a problem.
Is it possible to get information that would be simple to use to highlight the street from beginning to end by just passing street name to API? The maps that I would use do not have to be Google maps, they can be Yahoo, Bing on OpenStreetMap.
The goal is actually something like this:
As far as I know, none of the common web map APIs offer this facility. Two possible approaches come to mind, although neither one is straightforward or reliable:
a.) Download from OpenStreetMap a local set of all the road data that you want to be able to highlight in your application. Then, when your user enters the street name they are searching for, search the OSM data and construct a polyline from the relevant coordinate points and plot it on the map. The problem with this approach is that it requires you to host and maintain a complete set of road data, and also implement the appropriate parsing algorithm to deal with misspellings of street names etc. You may often find that road names as they appear on Google Maps will be spelled differently than they are in OSM, for example.
b.) Use a routing service to calculate a route from one end of the street to the other, and then plot a polyline that follows the points of the route. e.g. Using the Bing Maps Routes API (http://msdn.microsoft.com/en-us/library/ff701717.aspx), you could plot a route between the two intersections at either end of the road in question - e.g. "Av. Montaigne & Rond-point des Champs-Élysées" to "Av. Montaigne & Place de L'Alma". You could then plot a polyline from the route points as follows:
There are two problems with this approach: first, you need to know the names of the roads with which the street intersects at either end (or some other way of identifying the ends of the street in question), and secondly, the route chosen between those two intersections may not actually follow the street itself (for example, if the street is one-way and you try to calculate a route in the other direction).
I have a script that generates a ton of locations/places based on a users input. I want to add these places as markers on Google Maps based on javascript APIv3, but I would easily go over the geocoding limit.
Is there a way simply to insert a string of a popular location into the markers options variable and have it load on the map? So insert "Boston, USA" instead of latlng(X,Y)? Are their other options available to me? I know of free geocoding APIs, but not all my locations are in the US.
The only way to specify a Marker's location in Google Maps JavaScript API v3 is with a LatLng object. You cannot specify the Marker's location with a common name like "Boston, USA".
One thing you may want to consider is how a map will perform with lots of Markers. (I'm assuming by "a ton" you mean at least 500.) That might heavily tax your user's computer/device and the user may end up with little more than a blob of markers that's less than completely useful. Perhaps you can test with, say, 1000 markers on a less-than-kickass machine and see how your code performs. You may find that you need to rethink your interface in a way that reduces the number of markers you use anyway.
Is it possible to do a google map lookup using the google maps API from a UK postcode? I know you can search by UK postcode on their website, but this converts to lat / long. I don't have access to the PAF database to be able to convert to long / lat.
An example:
Users have an item to sell. One of the details of that item is a postcode, where the user / item is located. When the items are displayed on the front end of the website, there needs to be a google map of the items location generated using the postcode.
If this is possible, how do I do it?
What about using:
<img src="http://maps.google.com/maps/api/staticmap?center=POSTCODEHERE&zoom=14&size=200x200&maptype=roadmap&markers=color:ORANGE|label:A|POSTCODEHERE&sensor=false" style="float: right">
Then replace POSTCODEHERE in the two sections above with their postcode.
You can change the size from 200x200 or the marker colour, label etc. too if you wish.
You can do it purely though Google maps.
I did it for a client earlier this year and have just had to do a few modifications. I also did some direction-grabbing. It's all pretty simple but best viewed in context.
Take a look at the source of the page I made.
Google does not provide a geocoding api in the UK because of the licensing model the Royal Mail releases postcode data under.
The are however some tools that people have written that enable geocoding using google, but that would be technically illegal afaik.
One option then is to use one of the several uk geocoding providers. I don't want to sound lazy but they are easily googled. They typically charge a few pence per geocode.
It's (now) very easy to do this using google's LocalSearch API:
function usePointFromPostcode(postcode, callbackFunction) {
localSearch.setSearchCompleteCallback(null, function() {
if (localSearch.results[0]) {
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
callbackFunction(point);
} else {
alert("Postcode not found!");
}
});
localSearch.execute(postcode + ", UK");
}
callbackFunction() will receive a GLatLng object with, in my experience, very accurate coordinates. In fact, it's trivial to then feed that GLatLng to a GClientGeoCoder's getLocations() method and get back full Placemark details, which include details down to the level of address range (e.g. 1-18 Foo Street).
The real question is: how legal is that?
you need the PAF database, each postcode is held as a polygon, so unless you have that initial data you cannot restrict the search to the polygon, or to a radius around the centrepoint.
The postoffice will sell you all the data you require though, prices start from £85pa.
PS. Google does it because they have the PAF database, when you type in the postcode, they lookup the centre and display that on their map.
The folks behind openstreetmap.org have been working on a free equivalent - I don't know how ready for prime time it is, but FWIW:
http://freethepostcode.org/
http://www.websemantics.co.uk/resources/postcode_to_coordinates_conversion_tool/
Site will provide you with a longitude and latitude which you can place right into your google code.
Small UK business or charity can apply for a free licence of use PAF.
https://www.poweredbypaf.com/register-for-free-use-of-paf/
No one seems to have searched very hard... there is a freely available list of UK postcodes and positions out there. More importantly its all redundant because Google maps provides the ability to search by post code to begin with. Even using the API is a redundant extra given that the service is provided over the internet... there is nothing to stop you sending a http request yourself and displaying portions of the returned data, as long as you preserve any necessary copyright messages etc..