Skip to content

Commit

Permalink
Added maxZoom and minZoom attributes to the map. Added gitignore and …
Browse files Browse the repository at this point in the history
…bowerrc files. Updated demo to show maxZoom and minZoom.
  • Loading branch information
mbykovskyy committed Aug 5, 2014
1 parent 2615b86 commit a2fb6fc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "../"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
13 changes: 12 additions & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@
<script src="../platform/platform.js"></script>
<link rel="import" href="google-map.html">
<link rel="import" href="google-map-directions.html">
<style>
#controlsToggle {
position: absolute;
left: 50%;
}
</style>
</head>
<body fullbleed>

<google-map latitude="37.779" longitude="-122.3892" disableDefaultUI fit>
<google-map latitude="37.779" longitude="-122.3892" minZoom="9" maxZoom="11" fit>
<google-map-marker latitude="37.779" longitude="-122.3892"
title="Go Giants!" draggable="true">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/49/San_Francisco_Giants_Cap_Insignia.svg/200px-San_Francisco_Giants_Cap_Insignia.svg.png" />
</google-map-marker>
</google-map>
<google-map-directions startAddress="San Francisco" endAddress="Mountain View"></google-map-directions>
<button id="controlsToggle" onclick="toggleControls()">Toggle controls</button>

<script>
var gmap = document.querySelector('google-map');
gmap.addEventListener('api-load', function(e) {
document.querySelector('google-map-directions').map = this.map;
});

function toggleControls() {
gmap.disableDefaultUI = !gmap.disableDefaultUI;
}
</script>
</body>
</html>
36 changes: 34 additions & 2 deletions google-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
- Handle removals and support .innerHTML = ''.
- Use <google-maps-api>.api instead of google.maps namespace.
-->
<polymer-element name="google-map" attributes="apiKey latitude longitude zoom showCenterMarker version map mapType disableDefaultUI fitToMarkers zoomable styles">
<polymer-element name="google-map" attributes="apiKey latitude longitude zoom showCenterMarker version map mapType disableDefaultUI fitToMarkers zoomable styles maxZoom minZoom">
<template>

<style>
Expand Down Expand Up @@ -403,6 +403,24 @@
*/
styles: {},

/**
* A maximum zoom level which will be displayed on the map.
*
* @attribute maxZoom
* @type number
* @default null
*/
maxZoom: null,

/**
* A minimum zoom level which will be displayed on the map.
*
* @attribute minZoom
* @type number
* @default null
*/
minZoom: null,

observe: {
latitude: 'updateCenter',
longitude: 'updateCenter'
Expand Down Expand Up @@ -432,7 +450,9 @@
disableDefaultUI: this.disableDefaultUI,
disableDoubleClickZoom: !this.zoomable,
scrollwheel: this.zoomable,
styles: this.styles
styles: this.styles,
maxZoom: Number(this.maxZoom),
minZoom: Number(this.minZoom)
};

// Only override the default if set.
Expand Down Expand Up @@ -506,6 +526,18 @@
}
},

maxZoomChanged: function() {
if (this.map) {
this.map.setOptions({maxZoom: Number(this.maxZoom)});
}
},

minZoomChanged: function() {
if (this.map) {
this.map.setOptions({minZoom: Number(this.minZoom)});
}
},

mapTypeChanged: function() {
if (this.map) {
this.map.setMapTypeId(this.mapType);
Expand Down

0 comments on commit a2fb6fc

Please sign in to comment.