JSFiddle - React, Tailwind, and code Playground
by Gonzalo
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Google Maps API v3 Geocoder Tool</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body>
<div id="mapcontainer">
<div id="map"></div>
<div id="boundsLegend">Bounds</div>
<div id="viewportLegend">Viewport</div>
</div>
<div id="matches"></div>
</body>
</html>
CSS
#mapcontainer {
position: relative;
width: 640px;
height: 480px;
margin: 10px;
float: left;
}
#map {
width: 100%;
height: 100%;
border: 1px solid black;
position: absolute;
}
#boundsLegend,#viewportLegend {
position: absolute;
background-color: white;
right: 1px;
font-family: sans-serif;
font-size: small;
padding: 2px;
color: #222222;
display: none;
}
#boundsLegend {
border: 1px solid red;
bottom: 40px;
}
#viewportLegend {
border: 1px solid blue;
bottom: 15px;
}
#responseStatus {
display: none;
}
#responseCount {
display: none;
}
#responseInfo {
margin-top: 10px;
margin-left: 10px;
background-color: #eeeeee;
border: 1px solid #999999;
padding: 10px;
width: 620px;
display: none;
}
.info {
border-top: 1px solid #666666;
padding: 4px;
padding-left: 8px;
font: 10pt sans-serif;
margin-left: 4px;
margin-right: 4px;
cursor: pointer;
background-color: white;
}
.infoWindowContent {
width: 272px;
height: 120px;
overflow: auto;
}
.tabContent {
font: 10pt sans-serif;
border-collapse: collapse;
table-layout: auto;
}
#matches {
margin-top: 10px;
width: 320px;
height: 490px;
float: left;
border: 1px solid #666666;
display: none;
overflow: auto;
}
h1 {
border-bottom: 1px solid #999999;
font-family: sans-serif;
padding-bottom: 12px;
width: 650px;
margin-bottom: 0px;
}
#inputForm {
width: 650px;
margin: 10px;
}
#footer {
padding-top: 4px;
font-family: sans-serif;
font-size: 8pt;
clear: both;
width: 650px;
border-top: 1px solid #999999;
}
#instructions {
padding-bottom: 8px;
}
.key {
text-align: right;
font-weight: bold;
vertical-align: top;
white-space: nowrap
}
.value {
vertical-align: top;
}
#options {
margin-top: 5px;
}
#biasViewport,#country {
margin-right: 16px;
}
#newFeatures {
position: absolute;
top: 1px;
right: -2px;
background-color: #ffffd0;
border: 1px solid black;
font-family: sans-serif;
...
JavaScript
var MAPFILES_URL = "http://maps.gstatic.com/intl/en_us/mapfiles/";
var map = null;
var geocoder = null;
var shadow = null;
var clickIcon = null;
var clickMarker = null;
var markers = null;
var selected = null;
var infowindow = null;
var boundsOverlay = null;
var viewportOverlay = null;
var initialized = false;
var hashFragment = "";
var GeocoderStatusDescription = {
"OK": "The request did not encounter any errors",
"UNKNOWN_ERROR": "A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known",
"OVER_QUERY_LIMIT": "The webpage has gone over the requests limit in too short a period of time",
"REQUEST_DENIED": "The webpage is not allowed to use the geocoder for some reason",
"INVALID_REQUEST": "This request was invalid",
"ZERO_RESULTS": "The request did not encounter any errors but returns zero results",
"ERROR": "There was a problem contacting the Google servers"
};
var GeocoderLocationTypeDescription = {
"ROOFTOP": "The returned result reflects a precise geocode.",
"RANGE_INTERPOLATED": "The returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavilable for a street address.",
"GEOMETRIC_CENTER": "The returned result is the geometric center of a result such a line (e.g. street) or polygon (region).",
"APPROXIMATE": "The returned result is approximate."
}
function init() {
var params = parseUrlParams();
clearOptions();
setOptions(params);
var mapOptions = {
'zoom': (params.zoom ? params.zoom : 1),
'center': (params.center ? params.center : new google.maps.LatLng(0.0,0.0)),
'mapTypeId': google.maps.MapTypeId.ROADMAP,
'scaleControl': true
}
map = new google.maps.Map(document.getElementById("map"), mapOptions);
geocoder = new google.maps.Geocoder();
infowindow = new google.maps.InfoWindow({
'size':...