Skip to content

Instantly share code, notes, and snippets.

@astrotim
Created May 11, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrotim/7e78b247444a58858810 to your computer and use it in GitHub Desktop.
Save astrotim/7e78b247444a58858810 to your computer and use it in GitHub Desktop.
var stores = [],
store,
latLng,
features = null,
i, s;
for (i = 0; i < crtStores.stores.length; i++) {
s = crtStores.stores[i];
latLng = new google.maps.LatLng(s.lat, s.lng);
store = new storeLocator.Store(s.id, latLng, features, {
title: s.name,
address: s.address + ', ' + s.town + ' ' + s.state + ' ' + s.postcode,
address1: s.address + ', ',
address2: s.town + ' ' + s.state + ' ' + s.postcode,
street: s.address,
town: s.town,
postcode: s.postcode,
phone: s.phone
});
stores.push(store);
}
/**
* @extends storeLocator.StaticDataFeed
* @constructor
*/
function CrtDataSource() {
var dataFeed = new storeLocator.StaticDataFeed();
dataFeed.setStores(stores);
return dataFeed;
}
function initialize() {
var log = 0;
var marker = 'http://www.crt.com.au/wp-content/themes/crt/images/marker.png';
var mapOptions = {
center: new google.maps.LatLng(-28,135), //-33.976, 150.8
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
if($(window).width() < 600) {
mapOptions.zoomControl = false;
mapOptions.streetViewControl = false;
}
if(log) console.log(mapOptions);
var map = new google.maps.Map(document.getElementById('mapCanvas'), mapOptions);
var panelDiv = document.getElementById('listPanel');
var data = new CrtDataSource();
var view = new storeLocator.View(map, data, {
geolocation: false,
markerIcon: marker
});
new storeLocator.Panel(panelDiv, {
view: view,
locationSearchLabel: 'Postcode or location name',
directions: false
});
}
google.maps.event.addDomListener(window, 'load', initialize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment