So if I have a general GPS Lat/Lng point, would it be possible to say, yes this point is in a building, or this point is on a road which a car could travel on?
To predict what traffic will look like in the near future, Google Maps analyzes historical traffic patterns for roads over time. The software then combines this database of historical traffic patterns with live traffic conditions, using machine learning to generate predictions based on both sets of data.
To choose an alternate route, either click on a greyed-out route on the map or click on one of the other routes listed on the left-hand side menu. Note that you can also change routes by clicking on one and dragging it so that the directions will take you via certain roads.
You can see what some places look like on the inside before you visit. On Google Maps, you can see: The interior of places like stores, airports, or hotels.
I do not think you can determine if a point is a road or a building purely with Google Maps data. To do this I think you would need some additional data source.
However, you may be able to determine if a point is a road by using the Snap point to street technique.
I have re-written the technique to use Google Maps API v3 and added the Haversine function to tell you the distance (in km) between the original clicked point and the corresponding point in the nearest street.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Directions Simple</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
rad = function(x) {return x*Math.PI/180;}
distHaversine = function(p1, p2) {
var R = 6371; // earth's mean radius in km
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong/2) * Math.sin(dLong/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d.toFixed(3);
}
var dirn = new google.maps.DirectionsService();
var map;
function initialize() {
var center = new google.maps.LatLng(53.7877, -2.9832);
var myOptions = {
zoom:15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: center
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, "click", function(event) {
// == When the user clicks on a the map, get directiobns from that point to itself ==
var request = {
origin: event.latLng,
destination: event.latLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
dirn.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
if(response.routes && response.routes.length > 0){
route = response.routes[0];
if(route.overview_path && route.overview_path.length > 0){
pos = route.overview_path[0];
new google.maps.Marker({
position: pos,
map: map
});
alert(distHaversine(request.origin, pos));
}
}
}
});
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>
I hope this is helpful.
Best place to ask is https://gis.stackexchange.com/. Isn't it possible to figure out the road location from the layer which contains the roads? You'll be given the lat-long's of all road nodes. Unless it's a curved line, you can find if your lat-long point lies on the road line. To convert lat-long to cartesian, follow the link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With