Created
July 14, 2014 19:09
-
-
Save batjko/0385ed2699563487448d to your computer and use it in GitHub Desktop.
designer
This file contains 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="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-field/core-field.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> | |
<link rel="import" href="../core-input/core-input.html"> | |
<link rel="import" href="../core-icons/core-icons.html"> | |
<link rel="import" href="../speech-mic/speech-mic.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../google-map/google-map-search.html"> | |
<link rel="import" href="../google-map/google-map-directions.html"> | |
<link rel="import" href="../google-map/google-map.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
box-sizing: border-box; | |
} | |
#core_scaffold { | |
position: absolute; | |
top: 0px; | |
right: 0px; | |
bottom: 0px; | |
left: 0px; | |
width: 100%; | |
height: 100%; | |
} | |
#core_header_panel { | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
width: 100%; | |
height: 100%; | |
background-color: rgb(255, 255, 255); | |
} | |
#core_toolbar { | |
color: rgb(255, 255, 255); | |
background-color: rgb(79, 125, 201); | |
} | |
#core_menu { | |
font-size: 16px; | |
} | |
#google_map { | |
width: 100%; | |
height: 100%; | |
display: block; | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
} | |
#core_field { | |
background-color: rgb(255, 255, 255); | |
} | |
#core_icon { | |
height: 24px; | |
width: 24px; | |
} | |
#core_icon1 { | |
height: 24px; | |
width: 24px; | |
} | |
</style> | |
<core-scaffold id="core_scaffold"> | |
<core-header-panel mode="seamed" id="core_header_panel" navigation flex> | |
<core-toolbar id="core_toolbar"> | |
<core-field id="core_field" icon="search" theme="core-light-theme" center horizontal layout> | |
<core-icon icon="search" id="core_icon"></core-icon> | |
<core-input placeholder="text input" inputvalue="Potsdam" value="{{ $.speech_mic.transcript }}" id="core_input" flex></core-input> | |
<speech-mic transcript="Potsdam" id="speech_mic"></speech-mic> | |
</core-field> | |
</core-toolbar> | |
<core-menu selected="Navigate" valueattr="label" selectedindex="2" id="core_menu" theme="core-light-theme"> | |
<core-item label="Roadmap" icon="star" size="24" id="roadmap" on-tap="{{ showRoad }}" horizontal center layout></core-item> | |
<core-item label="Satellite" icon="add-circle-outline" size="24" id="satellite" on-tap="{{ showSat }}" horizontal center layout></core-item> | |
<core-item label="Navigate" icon="settings" size="24" id="navigate" on-tap="{{ showNavigator }}" horizontal center layout active></core-item> | |
</core-menu> | |
<google-map-search map="{{ $.google_map.map }}" query="{{ $.core_input.value }}" id="google_map_search"></google-map-search> | |
<google-map-directions map="{{ $.google_map.map }}" endaddress="{{ $.core_input.value }}" travelmode="WALKING" id="navimap"></google-map-directions> | |
</core-header-panel> | |
<div id="div" tool class="walktitle">Map Test</div> | |
<google-map latitude="{{ $.google_map_search.result.latitude }}" longitude="{{ $.google_map_search.result.longitude }}" zoom="18" showcentermarker id="google_map"></google-map> | |
</core-scaffold> | |
</template> | |
<script> | |
Polymer('my-element', { | |
showRoad: function () { | |
this.$.google_map.mapType='roadmap'; | |
}, | |
showSat: function () { | |
this.$.google_map.mapType='satellite'; | |
}, | |
showNavigator: function (){ | |
if (navigator.geolocation) { | |
var timeoutVal = 10 * 1000 * 1000; | |
var navigateMe = function (position){ | |
console.log("Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude); | |
console.dir(position); | |
// set current location | |
this.$.navimap.startaddress = position.coords.latitude+","+position.coords.longitude; | |
// start navigatn' | |
this.$.navimap.route(); | |
} | |
var showLocError = function(error){ | |
var errors = { | |
1: 'Permission denied', | |
2: 'Position unavailable', | |
3: 'Request timeout' | |
} | |
alert("Error: " + errors[error.code]); | |
} | |
console.log("Getting current location..."); | |
// find location | |
navigator.geolocation.getCurrentPosition( | |
// on success: do the routing boogie | |
navigateMe, | |
// on error: complain | |
showLocError, | |
// geolocation options | |
{ enableHighAccuracy: true, | |
timeout: timeoutVal, | |
maximumAge: 0 | |
} | |
); | |
} | |
else { | |
alert("Geolocation is not supported by this browser"); | |
} | |
} // showNavigator | |
}); // Polymer | |
</script> | |
</polymer-element> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment