forked from juliamae/geo-autocomplete
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-factored geo-autocomplete widget to accept some more useful option…
…s. more demos added.
- Loading branch information
hitching
committed
Oct 7, 2010
1 parent
e318c20
commit 37c3506
Showing
2 changed files
with
101 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,64 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> | ||
|
||
<title>jQuery geo_Autocomplete Plugin</title> | ||
<title>geo-autocomplete demos</title> | ||
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | ||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> | ||
<link type="text/css" href="../lib/jquery-ui/css/ui-lightness/jquery-ui-1.8.5.custom.css" rel="Stylesheet" /> | ||
<script type="text/javascript" src="../lib/jquery-ui/js/jquery-ui-1.8.5.custom.min.js"></script> | ||
<script type="text/javascript" src="../ui.geo_autocomplete.js"></script> | ||
|
||
<script type="text/javascript"> | ||
$().ready(function() { | ||
demo1(); | ||
demo2(); | ||
demo3(); | ||
demo4(); | ||
}); | ||
|
||
function demo1() { | ||
$('#demo1_location').geo_autocomplete(); | ||
} | ||
|
||
var latlng = new google.maps.LatLng(-34.397, 150.644); | ||
var myOptions = { | ||
zoom: 8, | ||
center: latlng, | ||
mapTypeId: google.maps.MapTypeId.ROADMAP | ||
}; | ||
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | ||
|
||
// use all the autocomplete options as documented at http://jqueryui.com/demos/autocomplete | ||
/* additional geo_autocomplete options: | ||
map: the google.maps.Map object to relocate | ||
mapwidth : 100 | ||
mapheight : 100 | ||
maptype : 'terrain' (see http://code.google.com/apis/maps/documentation/staticmaps/#MapTypes) | ||
mapsensor : true or false | ||
*/ | ||
$('#location').geo_autocomplete({ | ||
// this example relocates the map | ||
select: function(event, ui) { | ||
if (ui.item.viewport) map.fitBounds(ui.item.viewport); | ||
// the select function uses the viewport of the chosen location to relocate the map | ||
function demo2() { | ||
var map = new google.maps.Map(document.getElementById("demo2_map"), { mapTypeId: google.maps.MapTypeId.ROADMAP }); | ||
|
||
$('#demo2_location').geo_autocomplete({ | ||
select: function(_event, _ui) { | ||
if (_ui.item.viewport) map.fitBounds(_ui.item.viewport); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function demo3() { | ||
$('#demo3_location').geo_autocomplete({ | ||
geocoder_region: 'Africa', | ||
geocoder_types: 'country', | ||
mapheight: 100, mapwidth: 200, maptype: 'hybrid' | ||
}); | ||
} | ||
|
||
</script> | ||
|
||
<link type="text/css" href="../lib/jquery-ui/css/ui-lightness/jquery-ui-1.8.5.custom.css" rel="stylesheet" /> | ||
<style type="text/css"> | ||
.ui-autocomplete { overflow-y: auto; width:300px; } | ||
* html .ui-autocomplete { /* IE max- */height: expression( this.scrollHeight > 320 ? "320px" : "auto" ); } | ||
.ui-autocomplete { max-height: 320px; } | ||
.ui-autocomplete li { font-size:10pt; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<h3><a href="http://code.google.com/p/geo-autocomplete">jQuery geo-autocomplete Plugin</a> Demo</h3> | ||
<h1>geo-autocomplete demos</h1> | ||
<h3>Basic use</h3> | ||
<p>Location: <input type="text" id="demo1_location" size="50" /></p> | ||
|
||
<p>Updated 6 Oct 2010: Now built upon jQuery UI Autocomplete. You can still try the <a href="index.html">previous version</a>.</p> | ||
<h3>Fast map relocation</h3> | ||
<p>Location: <input type="text" id="demo2_location" size="50" /></p> | ||
<div id="demo2_map" style="width:400px;height:300px;"></div> | ||
|
||
<div>Location: <input type="text" id="location" /> (autocomplete)</div> | ||
<br/> | ||
<div id="map_canvas" style="width:500px;height:350px;"/> | ||
<h3>Restricted to Countries within Africa</h3> | ||
<p>Location: <input type="text" id="demo3_location" size="50" /></p> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters