var map;
var service;
var infowindow;
var service;
var place;
var placesearch;
function initialize() {
//set up google map
map = new google.maps.Map(document.getElementById('map_canvas'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(-27.420538,153.028107),
zoom: 10
});
//initialize places service to perform TextSearch
service = new google.maps.places.PlacesService(map);
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759),
new google.maps.LatLng(-33.8474, 151.2631));
var input = document.getElementById('searchfield');
var options = {
bounds: defaultBounds,
types: []
};
autocomplete = new google.maps.places.Autocomplete(input, options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
place = autocomplete.getPlace();
placesearch = $('#searchfield').val();
if (!place.geometry) {
// Inform the user that a place was not found and return.
return;
}
updateMap();
});
}
function updateMap() {
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
// Use the viewport if it is provided.
map.fitBounds(place.geometry.viewport);
} else {
// Otherwise use the location and set a chosen zoom level.
map.setCenter(place.geometry.location);
map.setZoom(17);
}
}
function validateForm() {
searchfield = $('#searchfield').val();
if (searchfield == "" || searchfield == null) {
// No text entered
alert('Please enter text');
return false;
} else if (place && searchfield == placesearch) {
// Success
// return true to submit the form
updateMap();
alert('WADDUP!! Form submitted successfully bru!');
place = null;
placesearch = "";
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.