Skip to content

Commit

Permalink
Move sensor and version to attributes instead of hardcoding them.
Browse files Browse the repository at this point in the history
Users may need to indicate they are using a sensor, or load a different version of the API.
  • Loading branch information
bamnet committed Mar 4, 2014
1 parent 99cd57d commit 52f65a0
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 52f65a0

Please sign in to comment.