Skip to content

Instantly share code, notes, and snippets.

@popkinj
Created February 16, 2014 23:56
Show Gist options
  • Save popkinj/9042402 to your computer and use it in GitHub Desktop.
Save popkinj/9042402 to your computer and use it in GitHub Desktop.
A slightly more complex BC Geocoder example
<!doctype html>
<html>
<head>
<title>BC Geocoder Test Page</title>
<meta charset="utf-8"/>>
</head>
<body>
<div class="container">
<h1 class="title"><span class="kinda">kinda</span>Simple Geocoder</h1>
<!--
- All geocoder variables can be specified through data attributes.
- I've only added a couple options here.
-->
<input
type="text"
class="bc-geocoder typeahead"
data-output-S-R-S=3005
data-template="accuracy"
data-max-results=5
data-callback="showCoords"
autocomplete="off"
placeholder="Find a place"
x-webkit-speech/>
<div id="output"></div>
</div>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="bc-geocoder.js"></script>
<script type="text/javascript">
function showCoords (data) {
var html = "<p class='coords'>Albers Longitude: "+data.lon+", Latitude: "+data.lat+"</p>"+
"<p class='meta'>Locality type is "+data.localityType+"</p>"+
"<p class='meta'>Location descriptor is "+data.locationDescriptor+"</p>"+
"<p class='meta'>Positional Accuracy is "+data.locationPositionalAccuracy+"</p>";
$("#output").fadeOut(function () {
$(this).
html(html).
fadeIn();
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment