Fetching contributors…
Cannot retrieve contributors at this time
109 lines (86 sloc) 3.61 KB
<!DOCTYPE html>
<title>Aeris.js - Geosearch Example</title>
<!-- Leaflet -->
<link rel="stylesheet" href=""/>
<script type="text/javascript" src=""></script>
<link rel="shortcut icon" type="image/x-icon" href="../weather.ico"/>
<link rel="stylesheet" href="../css/example.css"/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="../apikeys.js"></script>
<div id="map-canvas"></div>
<div id="loading">Loading...</div>
<div class="prompt">
<h1>Geolocation Example</h1>
This example demonstrates the usage of aeris geolocation services. <b>Click the "Find Me!"</b> to trigger geolocation. The app will attempt to use <a href="" target="_blank">native HTML5 geolocation</a>, or fallback to IP-based geolocation using <a href="" target="_blank">freegeoip</a>.
Don't believe it's working? Check out this <a href="" target="_blank">manual geolocation</a> extension for chrome.
Having trouble? <br>
Make sure you've created a <code>apikeys.js</code> file, with a valid Aeris <code>client_id</code> and <code>client_secret</code>.
<div class="controls">
<button id="findMe">Find me!</button>
<script type="text/javascript">
var map = new aeris.maps.Map('map-canvas');
// Configure Aeris API keys (required for the AerisGeolocateService)
// Want to test out the IP-based geolocation?
// Just comment out this line to turn off HTML5
// geolocation:
// window.navigator = null;
$('#findMe').click(function() {
var geolocateService;
// Check if HTML5 geolocation is available
if (aeris.geolocate.HTML5GeolocateService.isSupported()) {
geolocateService = new aeris.geolocate.HTML5GeolocateService();
else {
// Fallback to IP-based geolocation
geolocateService = new aeris.geolocate.AerisGeolocateService();
// Run the geolocator
// `done` callback receives an
// aeris.geolocate.results.GeolocatePosition
// object.
done(function(position) {
// Create a marker on the map
// where the user is located.
var marker = new aeris.maps.markers.Marker({
position: position.latLon
var infoBox = new aeris.maps.InfoBox({
position: position.latLon,
content: 'You are here!'
// Center the map at location
// `fail` callback receives an
// aeris.geolocate.errors.GeolocateServiceError
// object
fail(function(err) {
throw err;