HTML and CSS Reference
In-Depth Information
return
d
;
}
Number
.
prototype
.
toRad
=
function
()
{
return
this
*
Math
.
PI
/
180
;
}
This distance calculation, along with many others, is available at
http://www.movable-
type.co.uk/scripts/latlong.html
under the Creative Commons Attribution 3.0 License.
A Practical Use Case: Reverse Geocoding
The term “geocoding” generally refers to translating a human-readable address into a
location on a map. The process of doing the converse, translating a location on the map
into a human-readable address, is known as
reverse geocoding
. The following code is a
simple example of how to reverse geocode coordinates returned from the Geolocation
API with the Google Maps API:
<!DOCTYPE html>
<html>
<head>
<meta
name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no"
>
<meta
charset=
"utf-8"
>
<title>
Google Maps JavaScript API v3 Example: Reverse Geocoding
</title>
<link
href=
"https://google-developers.appspot.com/maps/documentation/
javascript/examples/default.css"
rel=
"stylesheet"
>
<script
src=
"https://maps.googleapis.com/maps/api/js?sensor=false"
>
</script>
<script>
var
geocoder
;
var
map
;
var
infowindow
=
new
google
.
maps
.
InfoWindow
();
var
marker
;
function
initialize
()
{
geocoder
=
new
google
.
maps
.
Geocoder
();
var
latlng
=
new
google
.
maps
.
LatLng
(
40.730885
,
-
73.997383
);
var
mapOptions
=
{
zoom
:
8
,
center
:
latlng
,
mapTypeId
:
'roadmap'
}
map
=
new
google
.
maps
.
Map
(
document
.
getElementById
(
'map_canvas'
),
mapOptions
);
}
function
codeLatLng
()
{
var
input
=
document
.
getElementById
(
'latlng'
).
value
;