Skip to content

Commit

Permalink
adding support for custom map styles
Browse files Browse the repository at this point in the history
  • Loading branch information
ekryski committed Jun 28, 2014
1 parent f6b213f commit c0078fc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion google-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,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">
<polymer-element name="google-map" attributes="apiKey latitude longitude zoom showCenterMarker version map mapType disableDefaultUI fitToMarkers zoomable styles">
<template>

<style>
Expand Down Expand Up @@ -383,6 +383,15 @@
*/
zoomable: true,

/**
* If set, custom styles can be applied to the map.
*
* @attribute styles
* @type JSON encoded array
* @default null
*/
styles: null,

observe: {
latitude: 'updateCenter',
longitude: 'updateCenter'
Expand All @@ -405,6 +414,15 @@
scrollwheel: this.zoomable
};

if (this.styles !== null) {
try {
mapOptions.styles = JSON.parse(this.styles);
}
catch(e) {
mapOptions.styles = this.styles;
}
}

// Only override the default if set.
// We use getAttribute here because the default value of this.draggable = false even when not set.
if (this.getAttribute("draggable") != null) {
Expand Down

0 comments on commit c0078fc

Please sign in to comment.