Last active
August 29, 2015 14:19
-
-
Save zhenyanghua/d56b86fb2bdfbd4656a1 to your computer and use it in GitHub Desktop.
Polymer with Google Maps API
This file contains hidden or 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
<link rel="import" href="../bower_components/core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../bower_components/core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../bower_components/core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../bower_components/paper-tabs/paper-tabs.html"> | |
<link rel="import" href="../bower_components/paper-tabs/paper-tab.html"> | |
<link rel="import" href="../bower_components/paper-button/paper-button.html"> | |
<link rel="import" href="../bower_components/core-icons/core-icons.html"> | |
<link rel="import" href="../bower_components/core-icon/core-icon.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/core-animated-pages.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/transitions/hero-transition.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/transitions/cross-fade.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/transitions/slide-down.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/transitions/slide-up.html"> | |
<link rel="import" href="../bower_components/core-animated-pages/transitions/tile-cascade.html"> | |
<link rel="import" href="../bower_components/paper-checkbox/paper-checkbox.html"> | |
<link rel="import" href="../bower_components/paper-input/paper-input.html"> | |
<link rel="import" href="../bower_components/google-apis/google-maps-api.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
box-sizing: border-box; | |
} | |
core-scaffold::shadow core-toolbar { | |
color: white; | |
background: rgb(255, 223, 0); | |
} | |
#core_scaffold { | |
position: absolute; | |
top: 0px; | |
right: 0px; | |
bottom: 0px; | |
left: 0px; | |
width: 100%; | |
height: 100%; | |
} | |
#core_header_panel { | |
background-color: rgb(255, 255, 255); | |
} | |
#core_toolbar { | |
color: rgb(255, 255, 255); | |
background-color: rgb(255, 255, 141); | |
} | |
#section { | |
width: 100%; | |
left: 0px; | |
top: 0px; | |
position: absolute; | |
height: 100%; | |
} | |
#paper_tabs1 { | |
color: rgb(255, 255, 255); | |
box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 2px; | |
background-color: rgb(0, 188, 212); | |
} | |
.place-explore { | |
margin: 20px 10px 20px 0px; | |
} | |
.place-item { | |
margin: 20px 10px 20px 40px; | |
} | |
.paper-checkbox { | |
margin: 20px 40px; | |
} | |
#map-canvas { | |
width: 100%; | |
height: 100%; | |
display: block; | |
left: 0px; | |
top: 0px; | |
position: absolute; | |
} | |
#paper_input { | |
left: 10px; | |
top: 0px; | |
position: relative; | |
} | |
.custom /deep/ *::-webkit-input-placeholder { | |
color: white; | |
} | |
.custom /deep/ .label-text, .custom /deep/ .error { | |
color: white; | |
} | |
.custom /deep/ .unfocused-underline { | |
background-color: white; | |
} | |
.custom[focused] /deep/ .floated-label .label-text { | |
color: rgb(15, 157, 88); | |
} | |
.custom /deep/ .focused-underline { | |
background-color: rgb(15, 157, 88); | |
} | |
.custom.invalid /deep/ .floated-label .label-text, .custom /deep/ .error { | |
color: rgb(240, 98, 146); | |
} | |
.custom.invalid /deep/ .focused-underline { | |
background-color: rgb(240, 98, 146); | |
} | |
.custom { | |
color: rgb(15, 157, 88); | |
} | |
#core_icon_search { | |
position: relative; | |
left: 14px; | |
} | |
</style> | |
<core-scaffold drawerwidth="320px" responsivewidth="900px" id="core_scaffold"> | |
<core-header-panel mode="seamed" id="core_header_panel" navigation flex> | |
<core-toolbar id="core_toolbar"> | |
</core-toolbar> | |
<section id="section" layout vertical is="auto-binding"> | |
<paper-tabs selected="{{ selected }}" selectedindex="0" id="paper_tabs1" horizontal center layout> | |
<paper-tab id="paper_tab3" inline flex center-center horizontal layout active>Food</paper-tab> | |
<paper-tab id="paper_tab4" inline flex center-center horizontal layout>Fun</paper-tab> | |
<paper-tab id="paper_tab5" inline flex center-center horizontal layout>Transit</paper-tab> | |
</paper-tabs> | |
<paper-button id="paper_button" on-click="{{ searchPlace }}"> | |
<core-icon icon="favorite-outline" class="place-explore"></core-icon> | |
<span>Explore</span> | |
</paper-button> | |
<core-animated-pages selected="{{ selected }}" lastselected="2" selectedindex="0" notap id="core_animated_pages" duration="500"> | |
<section id="section1" flex relative active> | |
<core-label center horizontal layout> | |
<core-icon icon="favorite" class="place-item"></core-icon> | |
<div flex>Bakery</div> | |
<paper-checkbox checked class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="store" class="place-item"></core-icon> | |
<div flex>Bar</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="store" class="place-item"></core-icon> | |
<div flex>Cafe</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="shopping-basket" class="place-item"></core-icon> | |
<div flex>Food</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="menu" class="place-item"></core-icon> | |
<div flex>Restaurant</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
</section> | |
<section id="section2" flex relative> | |
<core-label center horizontal layout> | |
<core-icon icon="face" class="place-item"></core-icon> | |
<div flex>Amusement Park</div> | |
<paper-checkbox checked class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="account-balance" class="place-item"></core-icon> | |
<div flex>Aquarium</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="account-balance" class="place-item"></core-icon> | |
<div flex>Art Gallery</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="group-work" class="place-item"></core-icon> | |
<div flex>Casino</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="theaters" class="place-item"></core-icon> | |
<div flex>Movie Theater</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="account-balance" class="place-item"></core-icon> | |
<div flex>Museum</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="stars" class="place-item"></core-icon> | |
<div flex>Stadium</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="android" class="place-item"></core-icon> | |
<div flex>Zoo</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
</section> | |
<section id="section3" flex relative> | |
<core-label center horizontal layout> | |
<core-icon icon="send" class="place-item"></core-icon> | |
<div flex>Airport</div> | |
<paper-checkbox checked class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="swap-vert" class="place-item"></core-icon> | |
<div flex>Bus Station</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="room" class="place-item"></core-icon> | |
<div flex>Car Rental</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="swap-vert" class="place-item"></core-icon> | |
<div flex>Subway Station</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
<core-label center horizontal layout> | |
<core-icon icon="account-balance" class="place-item"></core-icon> | |
<div flex>Train Station</div> | |
<paper-checkbox class="blue paper-checkbox" for></paper-checkbox> | |
</core-label> | |
</section> | |
</core-animated-pages> | |
</section> | |
</core-header-panel> | |
<div id="div" tool> | |
<span>Timeshare Finder</span> | |
<core-icon icon="search" id="core_icon_search"></core-icon> | |
<paper-input label="Look for a Timeshare..." id="paper_input" class="custom"></paper-input> | |
</div> | |
<google-maps-api apiKey="{{apiKey}}" clientId="{{clientId}}" version="{{version}}" on-api-load="{{mapApiLoaded}}" libraries="{{libraries}}" signedIn="{{signedIn}}"></google-maps-api> | |
<div id="map_canvas" style="position:absolute; height:100%; width:100%; transform:none;"></div> | |
</core-scaffold> | |
</template> | |
<script> | |
Polymer({ | |
// Tabs selector | |
selected: 0, | |
// Maps | |
map: null, | |
apiKey: null, | |
clientId: null, | |
libraries: "places", | |
version: '3', | |
signedIn: true, | |
mapApiLoaded: function() { | |
var map_canvas = this.$.map_canvas; | |
this.map = new google.maps.Map(map_canvas, this.getMapOptions()); | |
}, | |
getMapOptions: function() { | |
var mapOptions = { | |
center: new google.maps.LatLng(42, -71), | |
zoom: 8, | |
mapType: 'roadmap', | |
// styles: this.styles, | |
maxZoom: 18, | |
minZoom: 4 | |
}; | |
return mapOptions; | |
}, | |
searchPlace: function(event, detail, sender) { | |
console.log(event, detail, sender); | |
console.log(this.map.panTo(new google.maps.LatLng(30, -85))); | |
}, | |
}); | |
</script> | |
</polymer-element> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment