Skip to content

Commit

Permalink
Merge pull request #1 from bamnet/master
Browse files Browse the repository at this point in the history
Move sensor and version to attributes instead of hardcoding them.
  • Loading branch information
frankiefu committed Apr 7, 2014
2 parents e3bd371 + 52f65a0 commit f5a0a94
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions google-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<link rel="import" href="../polymer/polymer.html">

<polymer-element name="google-map" attributes="latitude longitude zoom showCenterMarker map">
<polymer-element name="google-map" attributes="latitude longitude zoom showCenterMarker version sensor map">
<template>
<style>
:host {
Expand All @@ -40,11 +40,11 @@
<script>
(function() {
var CALLBACK_NAME = 'polymer_google_map_callback';
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false&callback=' + CALLBACK_NAME;
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?libraries=places&callback=' + CALLBACK_NAME;
var pendingCallbacks = [];
var loading;

function loadMapApi(callback) {
function loadMapApi(callback, version, sensor) {
if (window.google && window.google.maps) {
callback();
return;
Expand All @@ -53,7 +53,7 @@
loading = true;
window[CALLBACK_NAME] = mapApiLoaded.bind(this);
var s = document.createElement('script');
s.src = MAP_URL;
s.src = MAP_URL + '&v=' + version + '&sensor=' + sensor;
document.head.appendChild(s);
}
pendingCallbacks.push(callback);
Expand All @@ -71,12 +71,14 @@
longitude: '-122.41942',
zoom: 10,
showCenterMarker: false,
version: '3.exp',
sensor: false,
observe: {
latitude: 'updateCenter',
longitude: 'updateCenter'
},
ready: function() {
loadMapApi(this.mapReady.bind(this));
loadMapApi(this.mapReady.bind(this), this.version, this.sensor);
},
enteredView: function() {
this.resize();
Expand Down

0 comments on commit f5a0a94

Please sign in to comment.