Created
May 11, 2015 23:39
-
-
Save astrotim/7e78b247444a58858810 to your computer and use it in GitHub Desktop.
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
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