<html>
<head>
<title>Place Autocomplete</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
.controls {
margin-top: 16px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
padding: 0 11px 0 13px;
width: 400px;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
text-overflow: ellipsis;
}
#pac-input:focus {
border-color: #4d90fe;
margin-left: -1px;
padding-left: 14px; /* Regular padding-left + 1. */
width: 401px;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<link rel="stylesheet" href="http://mottie.github.io/Keyboard/css/keyboard.css">
<script src="http://mottie.github.io/Keyboard/js/jquery.keyboard.js"></script>
<script>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(40.714299, -74.00581540000002),
zoom: 13
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var input = /** @type {HTMLInputElement} */(
document.getElementById('pac-input'));
var types = document.getElementById('type-selector');
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(types);
window.autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map
});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17); // Why 17? Because it looks good.
}
marker.setIcon(/** @type {google.maps.Icon} */({
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(35, 35)
}));
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
infowindow.open(map, marker);
});
// Sets a listener on a radio button to change the filter type on Places
// Autocomplete.
function setupClickListener(id, types) {
var radioButton = document.getElementById(id);
google.maps.event.addDomListener(radioButton, 'click', function() {
autocomplete.setTypes(types);
});
}
setupClickListener('changetype-all', []);
setupClickListener('changetype-establishment', ['establishment']);
setupClickListener('changetype-geocode', ['geocode']);
}
google.maps.event.addDomListener(window, 'load', initialize);
$(function(){
initialize();
$('#pac-input').keyboard({
usePreview: false,
position : {
of : $('body'), // optional - null (attach to input/textarea) or a jQuery object (attach elsewhere)
my : 'center bottom',
at : 'center bottom',
at2: 'center bottom' // used when "usePreview" is false (centers keyboard at bottom of the input/textarea)
},
change : function(e, keyboard, el) {
google.maps.event.trigger(autocomplete, 'place_changed');
}
});
})
</script>
</head>
<body>
<input id="pac-input" class="controls" type="text" placeholder="Enter a location"/>
<div id="type-selector" class="controls">
<input type="radio" name="type" id="changetype-all" checked="checked"/>
<label for="changetype-all">All</label>
<input type="radio" name="type" id="changetype-establishment"/>
<label for="changetype-establishment">Establishments</label>
<input type="radio" name="type" id="changetype-geocode"/>
<label for="changetype-geocode">Geocodes</label>
</div>
<div id="map-canvas"></div>
</body>
</html>
body {
padding: 0;
margin: 0;
background: #3FA8C6;
background-image: linear-gradient(top, #3fa8c6 0%, #3fa8c6 0%, #399ab2 100%);
background-image: gradient(linear, left top, left bottom, color-stop(0%,#3fa8c6), color-stop(0%,#3fa8c6), color-stop(100%,#399ab2));
background-image: linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
background-image: linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
background-image: linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
background-image: linear-gradient(to bottom, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
color: #fff;
font-family: 'Doppio One', sans-serif;
text-shadow: 0 1px 0 rgba(0,0,0,.3);
line-height: 1.5;
font-smoothing: antialiased;
}
.wrapper {
width: 50%;
margin: 0 auto;
}
h1, h2, h3, h4, h5, h6 {
letter-spacing: -0.03em;
font-size: 2em;
}
a {
border-bottom: 1px solid #fff;
border-bottom: 1px solid rgba(255,255,255,0.7);
padding-bottom: 0.15em;
position: relative;
color: white;
text-decoration: none;
}
a:after {
content: '';
position: absolute;
height: 1px;
left: 0;
right: 0;
bottom: -2px;
background: rgba(0,0,0,.1);
}
a:hover {
color: #C0E3EC;
}
h1 {
margin: 0.667em 0 0;
padding-left: 0.5em;
text-align: left;
}
h2 {
font-size: 1.5em;
}
small {
margin-top: 1em;
display: block;
font-style: italic;
font-size: 0.667em;
}
p em {
font-style: none;
}
#welcome {
position: relative;
overflow: hidden;
padding-bottom: 1em;
padding-left: 20px;
}
#welcome > div {
padding-top: 1px;
}
#dave {
float: left;
margin-top: 3em
}
#welcome > h2 {
margin-top: 0.5em;
padding-left: 0.5em;
margin-bottom: 0;
}
.bubble p {
line-height: 22px;
}
.bubble {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.1);
padding: 0.667em 1em;
position: relative;
}
.bubble:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid white;
border-right-color: inherit;
top: 50px;
left: -20px;
}
#features {
margin: 0.444em 0 0;
clear: both;
}
#features > h2 {
margin: 0;
}
#features ol {
position: relative;
padding: 1em 0 1.5em;
background: rgba(0,0,0,.1);
border-color: rgba(0,0,0,.1);
margin: 0;
overflow: hidden;
list-style: none;
counter-reset: item;
}
#features li {
width: 30%;
padding: 0 1.5%;
float: left;
text-align: center;
margin-bottom: 1em;
}
#features li h2 {
display: block;
padding: 1em;
margin: 0.667em auto 1em;
font-size: 1em;
line-height: 1em;
text-align: center;
background: rgba(0,0,0,.1);
border-radius: 2em;
box-shadow: inset 0 0 1em rgba(0,0,0,.1), 0 2px 2px rgba(255,255,255,.1);
}
#next > div {
width: 45%;
float: left;
padding: 0 2.5%;
}
img {
z-index: 1;
transition: transform 2s ease-in-out;
transition: transform 2s ease-in-out;
transition: transform 2s ease-in-out;
transition: transform 2s ease-in-out;
transition: transform 2s ease-in-out;
position: relative;
}
img:active {
transform: rotate(1440deg) scale(1.2);
transform: rotate(1440deg) scale(1.2);
transform: rotate(1440deg) scale(1.2);
transform: rotate(1440deg) scale(1.2);
transform: rotate(1440deg) scale(1.2);
}
@media screen and (max-width: 1200px) {
.wrapper {
width: 80%;
}
}
@media screen and (max-width: 768px) {
.wrapper {
width: auto;
margin: 0;
}
#welcome {
margin-right: 2.5%;
}
}
@media screen and (max-width: 500px) {
.wrapper {
text-align: center;
}
#dave {
float: none;
}
#welcome {
padding: 0 1.5em;
margin: 0;
}
h1 {
text-align: center;
margin-bottom: 0;
padding-left: 0;
font-size: 1.8em;
}
#welcome > h2 {
margin-bottom: 0.667em;
}
.bubble {
text-align: center;
}
.bubble:after {
display: none;
}
#features li {
width: 47%;
}
#features li:last-child {
float: none;
clear: both;
margin: 0 auto;
}
#next > div {
float none;
width: auto;
}
}
if (location.pathname === '/welcome' || location.pathname === '/welcome/') {
location = '/welcome/edit?html,live';
}
if (window.location.pathname.indexOf('/edit') !== -1) $('a.open').click(function (event) {
event.preventDefault();
window.top.$('a[href$="' + this.hash + '"]').mousedown().click();
});
var presses = 0;
var spin = [
"Woahohaohaohaahoahaohaohaohaohaoha...",
"Nononono...aiiiiiiiiiiiiieeeeeeee....",
"Aaaaaaaaaghhhhh...woahwoahwoahwoahwoah...",
"You're eeeeeeeeviiiiiiilllllllll....",
"Eee...eee...eee...eee...eee...",
"Woowoowoowoowoowoowoowoowoo..."
];
var stop = [
"Please... never again.",
"I'm so dizzy.",
"That's just... cruel.",
"Don't you have better things to do?",
"I can't feel my toes... oh wait, I don't have any toes!",
"This isn't fun anymore.",
"...",
"I'm going to be sick.",
"Uh-oh, I think I just dropped some tables...",
"Yep, I think I'm about to SQL-project everywhere...",
"SELECT * FROM `stomach`...",
"var_dump($result)...",
"+_+"
];
$('#dave').mousedown(function () {
$('#message').fadeOut(function () {
$(this).text(spin[presses % spin.length]);
presses = presses + 1;
}).fadeIn();
}).mouseup(function () {
$('#message').fadeOut(function () {
$(this).text(stop[presses % stop.length]);
}).fadeIn();
if( presses >= stop.length - 1 ) {
$(this).animate({left: '-999px'}, 1000 * 10, function () {
$(this).animate({left: '0'}, 1000 * 4);
presses = 0;
});
}
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |