Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Upgrade to JS modules, TypeScript and LitElement #438

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
bower_components
.idea
/node_modules

/google-map*.d.ts
/google-map*.d.ts.map
/google-map*.js
/google-map*.js.map
/maps-api.d.ts
/maps-api.d.ts.map
/maps-api.js
/maps-api.js.map
/lib
117 changes: 56 additions & 61 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
<!doctype html>
<!-- Copyright (c) 2015 Google Inc. All rights reserved. -->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Google Map demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../google-map.html">
<link rel="import" href="../google-map-marker.html">
<link rel="import" href="../google-map-poly.html">
<link rel="import" href="../google-map-directions.html">
<style>
body {
margin: 0;
height: 100vh;
}
#controlsToggle {
position: absolute;
left: 10%;
bottom: 10%;
}
</style>
</head>
<body class="fullbleed">
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Google Map demo</title>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script type="module" src="../google-map.js"></script>
<script type="module" src="../google-map-marker.js"></script>
<style>
body {
margin: 0;
height: 100vh;
}
#controlsToggle {
position: absolute;
left: 10%;
bottom: 10%;
}
</style>
</head>
<body>

<dom-bind>
<template is="dom-bind">
<google-map latitude="37.779" longitude="-122.3892" min-zoom="9" max-zoom="11"
language="en" api-key="[[apiKey]]">
<google-map-marker slot="markers" latitude="37.779" longitude="-122.3892" label="GG"
title="Go Giants!" draggable="true" drag-events>
<google-map
latitude="37.779"
longitude="-122.3892"
min-zoom="9" max-zoom="11"
language="en"
api-key="AIzaSyBSwhN8h_lqJB2s4Fs4YMh16QD1nb_NYKs">
<google-map-marker
latitude="37.779"
longitude="-122.3892"
label="GG"
title="Go Giants!" draggable="true" drag-events>
<img src="https://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-poly closed fill-color="red" fill-opacity=".25" stroke-weight="1">
Expand All @@ -39,43 +42,35 @@
</google-map>

<google-map-directions start-address="Oakland" end-address="Mountain View"
language="en" api-key="[[apiKey]]"></google-map-directions>
</template>
</dom-bind>
language="en" api-key="Z7ekrT3tbhl_dy8DCXuIuDDRc"></google-map-directions>
<button id="controlsToggle" onclick="toggleControls()">Toggle controls</button>

<button id="controlsToggle" onclick="toggleControls()">Toggle controls</button>
<script>
function toggleControls() {
var gmap = document.querySelector('google-map');
gmap.disableDefaultUi = !gmap.disableDefaultUi;
}

<script>
var t = document.querySelector('template');
if (location.origin === 'https://user-content-dot-custom-elements.appspot.com') {
t.apiKey = 'AIzaSyD3E1D9b-Z7ekrT3tbhl_dy8DCXuIuDDRc'; // TODO: update to your own API Key!
}
document.addEventListener('dom-change', function(e) {
var gmap = document.querySelector('google-map');
var directions = document.querySelector('google-map-directions');

function toggleControls() {
var gmap = document.querySelector('google-map');
gmap.disableDefaultUi = !gmap.disableDefaultUi;
}
gmap.addEventListener('api-load', function(e) {
document.querySelector('google-map-directions').map = this.map;
});

document.addEventListener('dom-change', function(e) {
var gmap = document.querySelector('google-map');
var directions = document.querySelector('google-map-directions');
var marker = document.querySelector('google-map-marker');
var poly = document.querySelector('google-map-poly');
var point = document.querySelector('google-map-point');

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

var marker = document.querySelector('google-map-marker');
var poly = document.querySelector('google-map-poly');
var point = document.querySelector('google-map-point');

marker.addEventListener('google-map-marker-dragend', function(e) {
var latLng = e.detail.latLng;
console.log('pin dropped', latLng.lat(), latLng.lng());
point.latitude = latLng.lat();
point.longitude = latLng.lng();
poly._buildPathFromPoints();
});
});
</script>
</body>
marker.addEventListener('google-map-marker-dragend', function(e) {
var latLng = e.detail.latLng;
console.log('pin dropped', latLng.lat(), latLng.lng());
point.latitude = latLng.lat();
point.longitude = latLng.lng();
poly._buildPathFromPoints();
});
});
</script>
</body>
</html>
60 changes: 29 additions & 31 deletions demo/kml.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
<!doctype html>
<!-- Copyright (c) 2015 Google Inc. All rights reserved. -->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Google Map Poly demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../google-map.html">
<link rel="import" href="../google-map-poly.html">
<style>
body {
margin: 0;
height: 100vh;
}
#toggleEdit {
position: absolute;
top: 10px;
left: 120px;
}
</style>
</head>
<body class="fullbleed">

<template is="dom-bind">
<google-map latitude="41.876" longitude="-87.624" zoom="11" kml="http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml" api-key="[[apiKey]]"></google-map>
</template>

<script>
if (location.origin === 'https://user-content-dot-custom-elements.appspot.com') {
var t = document.querySelector('template');
t.apiKey = 'AIzaSyD3E1D9b-Z7ekrT3tbhl_dy8DCXuIuDDRc'; // TODO: update to your own API Key!
}
</script>
</body>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Google Maps KML demo</title>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script type="module" src="../google-map.js"></script>
<script type="module" src="../google-map-kml-layer.js"></script>
<style>
body {
margin: 0;
height: 100vh;
}
#toggleEdit {
position: absolute;
top: 10px;
left: 120px;
}
</style>
</head>
<body>
<google-map
latitude="41.876"
longitude="-87.624"
zoom="11"
api-key="AIzaSyBSwhN8h_lqJB2s4Fs4YMh16QD1nb_NYKs">
<google-map-kml-layer
url="http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml">
</google-map-kml-layer>
</google-map>
</body>
</html>
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "google-map",
"version": "1.0.0",
"description": "google-map ==========",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GoogleWebComponents/google-map.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/GoogleWebComponents/google-map/issues"
},
"homepage": "https://github.com/GoogleWebComponents/google-map#readme",
"dependencies": {
"@types/googlemaps": "^3.30.16",
"lit-element": "^2.0.1"
},
"devDependencies": {
"@webcomponents/webcomponentsjs": "^2.2.7"
}
}
9 changes: 9 additions & 0 deletions src/google-map-kml-layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// <!-- Copyright (c) 2015 Google Inc. All rights reserved. -->

import { GoogleMapChildElement, customElement, property } from './lib/google-map-child-element.js';

@customElement('google-map-kml-layer')
export class GoogleMapKmlLayer extends GoogleMapChildElement {
@property()
url?: string;
}
Loading