I have the next routes:
The red one is goes from A to B, the blue one goes from A' to B' and the green one goes from A'' to B''. I have the lat/long for A,B, A', B', A'' and B'' (I'm using Google Maps API) and I want to know if there is an algorithm to determinate if two routes have the same direction.
For example, in the picture, the red and blue route have the same direction.
Find the bearing of B from A. Movable-type's page is the standard reference.
However you can also use the geometry library in Google Maps API v3:
var a = new google.maps.LatLng(...);
var b = new google.maps.LatLng(...);
var bearing = google.maps.geometry.spherical.computeHeading(a,b)
Related
I have got a drop down of State and cities .
Upon selection of a State , corresponding cities will be displayed and once clicked on Go button , i am showning that particular city uisng Google Map.
Could you please let me know if how is it posible to show that area around dashed or dotted lines ??
I see that Poly line doesn't suit my requirement as it draws only one line .
Right now i have got only latitude and longitude obtained via
$(document).on('click', '.gobtn', function(event) {
$.getJSON('https://maps.googleapis.com/maps/api/geocode/json?address=' + address + '', function(data) {
latitude_res = data.results[0].geometry.location.lat;
longitude_res = data.results[0].geometry.location.lng;
}).done(function() {
});
});
This is my simple jsfiddle how i am showing map
http://jsfiddle.net/ZLuTg/1010/
Could you please let me know how to draw dashed / dotted around the boundary of latitude amd longitude ??
How to draw boundary around the address based on latitude amd longitude
If have a way to find the boundaries for the location you can use polyline to draw the border. Just close the shape, by joining the first point back to the last point.
If you don't already have the boundaries, according to the answer to this question Google Maps API V3: How to get region border coordinates (polyline) data? and others, google maps will not provide the boundaries for you.
I'm using google static maps
I'm trying to display 2 groups (with option for more) of geo points.
Each group has different icon.
this url displays only the center icon with out others
http://maps.googleapis.com/maps/api/staticmap
?center=31.909440199627042,35.00186054020873
&zoom=14
&size=1200x1200
&markers=icon:http%3A%2F%2Ftinyurl.com%2F2ftvtt6|31.909440199627042,35.00186054020873|31.909440199627042,35.00186054020873
&markers=icon:http%3A%2F%2Ftinyurl.com%2F2ftvtt6|31.909440199627042,35.00186054020873|31.909440199627042,35.00186054020873&sensor=false
What am I doing wrong?
The problem is your request:
http://maps.googleapis.com/maps/api/staticmap
?center=31.909440199627042,35.00186054020873
&zoom=14
&size=1200x1200
&markers=icon:http%3A%2F%2Ftinyurl.com%2F2ftvtt6|31.909440199627042,35.00186054020873|31.909440199627042,35.00186054020873
&markers=icon:http%3A%2F%2Ftinyurl.com%2F2ftvtt6|31.909440199627042,35.00186054020873|31.909440199627042,35.00186054020873&sensor=false
First: why do you have 2 markers fields?
Then: your markers are at exactly the same locations... So you see only 1 pin.
If I try the following (removed the 2nd markers and changed a value) I see 2 pins:
http://maps.googleapis.com/maps/api/staticmap
?center=31.909440199627042,35.00186054020873
&zoom=14
&size=1200x1200
&markers=icon:http%3A%2F%2Ftinyurl.com%2F2ftvtt6|31.909440199627042,35.00186054020873|31.909440199627042,35.0000
&sensor=false
When I have a specific area of the operation (like city or town) but would like to travel from point A in that area to point B outside of that area how can I check the exact point of the intersection of a route and border of area on google map?
ts like A -> [ C ] -> B
where A and B are start and finish point of route
and C is exact point for route / border - so i need distance (A;C) and then distance (C;B) with information where C is (intersection of route and border)
its urgent for me,
cheers, Marcin
Is it possible to plot two routes at same time with Google maps api.
For Example
Route from city A to B
and Route from city C to D
In this case A,B and C,D are separated.
Thanks.
Here are two polylines on the same map; there doesn't appear to be a limit.
http://jsfiddle.net/Lqcde/3/
I didn't add the div panels (becomes too cluttered) but you can also show two sets of text directions. It's a bit confusing because both start points are shown as "A" and endpoints, "B". Add the following lines:
directionsDisplay.setPanel(document.getElementById("dir-1"));
directionsDisplay2.setPanel(document.getElementById("dir-2"));
<div id="dir-1"></div>
<div id="dir-2"></div>
I have a question about the GOOGLE MAP API. If you have more than two data that share similar address, how do you show the Pins Drop on the same address?
Example
You have data such as the following:
Name=>Ray | Address=>Melon Park, California, USA ;
Name=>John | Address=>Melon Park, California, USA ;
Name=>Steve | Address=>Melon Park, California, USA
You want to display 3 Pins Drop for the similar address on Google Map.
The post linked above has some good advice. Your options are really:
Offset the markers slightly, so instead of displaying them all on the same they are all on really close to each other. Just add add or subtract small delta to each of them.
Use different icons for each location. If you know the maximum number of markers that could overlap (like 4?) at the same location, you could make your own rotated icons, so instead of pointing "down" in the typical teardrop shape they could point left, right, or up.
Handle the data overlap in your infowindow / UI.
Adding small delta will work like this (this script is written in PHP):
$random_num_lat = .00065 * mt_rand(1, 10); // delta to the lat value added
$random_num_lng = .00065 * mt_rand(1, 10); // delta to the lon value added
$lat=$row['lat']+$random_num_lat;
$lon=$row['lon']+$random_num_lng;
//now in loop it will be three `enter code here`marker display seperate to each other
while ($row = mysql_fetch_array($query)) {
echo ("addMarker($lat, $lon,'<b>$name</b><br/>$desc1');\n");
}
I achieved this using a "spiderfier" to "spiderfy".
There is a GoogleMaps v3 Spidifier available here (demo).
Leaflet.js can also load GoogleMaps v3 and has a beautiful clustering spidifier available here (demo).
Note: Following is a more of hack than a solution:
Write an algorithm that checks for repeated coordinates in array.
When a duplicate is found, add a small value such as 0.000001 to the found coordinates.
Note that the smaller the value the more you have zoom in to see the difference.