How to draw boundary around the address based on latitude amd longitude in Google Map - google-maps

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.

Related

How to find the centre of GPX data

Let's say I have some location data from a gpx file.
EG: [36.735058, -3.6843662, 13],[36.73534, -3.6841993, 12],[36.735455, -3.684072, 7],[36.735596, -3.6841817, 6],[36.735943, -3.6840394, 4]
I would like to find the center point using PHP so that when the points are rendered on a map, the map is centered at the center.
I suppose the the center point is some kind of average based on all the points.
Maybe there exists some king of algorithm to calculate the center.
The way I would approach this is to find the furthest North and South points and then find the point between them and do the same with East and West to find latitude and longitude of the center.
I haven't actually tried doing this this yet. I am wondering is someone else has already worked out the best way of finding a center point from a group of coordinates.
Yes, it works by finding the max North South Eat and West points.
Something like this
//WORK OUT THE CENTER POINT
$max_long = max($long_array);
$min_long = min($long_array);
$center_long = ($max_long + $min_long) / 2;
$max_lat = max($lat_array);
$min_lat = min($lat_array);
$center_lat = ($max_lat + $min_lat) / 2;

How to implement an indoor custom google street view

I want to create an indoor google virtual tour using google street view. I've read all Google street view documentation specially "Providing Custom Street View Panoramas" part. but honestly I didn't get how to implement an indoor virtual tour. Let me explain the case. Suppose that I have two panorama images a and b.
image a:
1) How can I put those two white arrows in the images. and how can I set their position to point a correct position?
2) How can I link image a to b. so that when user clicks on one of the white arrow can navigate from image a to b?
3) how can I put that mouse pointer (gray arrow surrounded by a circle) to my images?
4) how can I add the cross sign on the images?
I am thankful if you give me some sample code other than those that I've seen on google street view documentation.
1/2 are demonstrated in this example.
function getReceptionPanoramaData() {
return {
location: {
pano: 'reception', // The ID for this custom panorama.
description: 'Google Sydney - Reception',
latLng: new google.maps.LatLng(-33.86684, 151.19583)
},
links: [{
heading: 195,
description: 'Exit',
pano: outsideGoogle.location.pano
}],
The links block creates white arrows, at specificed headings, to other panoramas (in this case, back to a default Street View one).

What is the difference between google maps circle radius [meters] and distances between center and a point on the circumference[meters]

I'm using Google Maps javascript v3.
I draw a circle on the map and I permit the user modify the radius.
Then, I send coordinates of the center and the radius in km to a server script.
I extract all the markers with distance less than the radius from the center. I use the Great Circle formula and MySql GEOPOINT objects to calculate the distance:
(6371 * acos (cos(radians(".$coord_X_center."))* cos(radians(X(GEOPOINT)))
* cos(radians(Y(GEOPOINT)) - radians(".$coord_Y_center."))
+ sin(radians(".$coord_X_center."))
* sin( radians(X(GEOPOINT) )))) AS Distance FROM table_markers c
HAVING Distance <= ".$radius." ORDER BY RATING desc,Distance;"
Now consider the example I prepared for you:
Example
If you modify the radius of the circle, just to exclude one marker, much more markers will disappear. This is because the distance calculated, between center and disappeared markers, is higher than the radius of the circle.
Why? What is the difference? Maybe Google Maps do not consider the Earth a sphere as I do in the formula above?
Update:
POST Request sent (double-checked with firebug):
centerx: 8.222424000000046
centery: 45.295839
radius: 60.84800957919576
They are casted:
$coord_X_center = number_format((float) $post_filtered['centerx'], 4, '.', '');
$coord_Y_center = number_format((float) $post_filtered['centery'], 4, '.', '');
$radius = (int) $post_filtered['radius'];
Answer, via formula above:
{"names":["PONT-SAINT-MARTIN","FONTAINEMORE","LILLIANES","PERLOZ","GABY"],
"positions":[{"Lat":"7.81191320621736","Lon":"45.5991574533545"},
{"Lat":"7.88378299041174","Lon":"45.6488324511642"},
{"Lat":"7.85828195583629","Lon":"45.6242900876236"},
{"Lat":"7.81139246615188","Lon":"45.6285105114389"},
{"Lat":"7.88397564319245","Lon":"45.7144850123829"}]}
The radius of the earth is 6378.1 kilometers (not 6371 km, at least according to Google).

Google static maps - group some points with custom marker

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

How to display two or more markers on the same location?

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.