Skip to content

Commit d1c2733

Browse files
Update dist folder [skip ci] (#826)
1 parent 2ce5159 commit d1c2733

36 files changed

+877
-4
lines changed

dist/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h1>Maps JSAPI Samples</h1>
5454
<li><a href='/samples/layer-data-simple/dist'>layer-data-simple</a></li>
5555
<li><a href='/samples/layer-data-style/dist'>layer-data-style</a></li>
5656
<li><a href='/samples/map-drawing-terradraw/dist'>map-drawing-terradraw</a></li>
57+
<li><a href='/samples/map-projection-simple/dist'>map-projection-simple</a></li>
5758
<li><a href='/samples/map-simple/dist'>map-simple</a></li>
5859
<li><a href='/samples/place-autocomplete-basic-map/dist'>place-autocomplete-basic-map</a></li>
5960
<li><a href='/samples/place-autocomplete-data-session/dist'>place-autocomplete-data-session</a></li>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended"
4+
],
5+
"parser": "@typescript-eslint/parser",
6+
"rules": {
7+
"@typescript-eslint/ban-ts-comment": 0,
8+
"@typescript-eslint/no-this-alias": 1,
9+
"@typescript-eslint/no-empty-function": 1,
10+
"@typescript-eslint/explicit-module-boundary-types": 1,
11+
"@typescript-eslint/no-unused-vars": 1
12+
}
13+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Google Maps JavaScript Sample
2+
3+
This sample is generated from @googlemaps/js-samples located at
4+
https://github.com/googlemaps-samples/js-api-samples.
5+
6+
## Setup
7+
8+
### Before starting run:
9+
10+
`npm i`
11+
12+
### Run an example on a local web server
13+
14+
`cd samples/map-projection-simple`
15+
`npm start`
16+
17+
### Build an individual example
18+
19+
`cd samples/map-projection-simple`
20+
`npm run build`
21+
22+
From 'samples':
23+
24+
`npm run build --workspace=map-projection-simple/`
25+
26+
### Build all of the examples.
27+
28+
From 'samples':
29+
30+
`npm run build-all`
31+
32+
### Run lint to check for problems
33+
34+
`cd samples/map-projection-simple`
35+
`npx eslint index.ts`
36+
37+
## Feedback
38+
39+
For feedback related to this sample, please open a new issue on
40+
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<!--
3+
@license
4+
Copyright 2019 Google LLC. All Rights Reserved.
5+
SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<!-- [START maps_map_projection_simple] -->
8+
<html>
9+
<head>
10+
<title>Custom Map Projections</title>
11+
12+
<link rel="stylesheet" type="text/css" href="./style.css" />
13+
<script type="module" src="./index.js"></script>
14+
<!-- prettier-ignore -->
15+
<script>(g => { var h, a, k, p = "The Google Maps JavaScript API", c = "google", l = "importLibrary", q = "__ib__", m = document, b = window; b = b[c] || (b[c] = {}); var d = b.maps || (b.maps = {}), r = new Set, e = new URLSearchParams, u = () => h || (h = new Promise(async (f, n) => { await (a = m.createElement("script")); e.set("libraries", [...r] + ""); for (k in g) e.set(k.replace(/[A-Z]/g, t => "_" + t[0].toLowerCase()), g[k]); e.set("callback", c + ".maps." + q); a.src = `https://maps.${c}apis.com/maps/api/js?` + e; d[q] = f; a.onerror = () => h = n(Error(p + " could not load.")); a.nonce = m.querySelector("script[nonce]")?.nonce || ""; m.head.append(a) })); d[l] ? console.warn(p + " only loads once. Ignoring:", g) : d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n)) })
16+
({ key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "beta" });</script>
17+
</head>
18+
<body>
19+
<gmp-map center="0,0" zoom="0">
20+
<div id="coords" slot="control-block-start-inline-center"></div>
21+
</gmp-map>
22+
</body>
23+
</html>
24+
<!-- [END maps_map_projection_simple] -->
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// [START maps_map_projection_simple]
8+
// This example defines an image map type using the Gall-Peters
9+
// projection.
10+
// https://en.wikipedia.org/wiki/Gall%E2%80%93Peters_projection
11+
const mapElement = document.querySelector("gmp-map") as google.maps.MapElement;
12+
let innerMap;
13+
14+
async function initMap() {
15+
// Request the needed libraries.
16+
await google.maps.importLibrary("maps");
17+
18+
// Create a map.
19+
innerMap = mapElement.innerMap;
20+
innerMap.setOptions({
21+
mapTypeControl: false,
22+
});
23+
24+
// Set the Gall-Peters map type.
25+
initGallPeters();
26+
innerMap.mapTypes.set("gallPeters", gallPetersMapType);
27+
innerMap.setMapTypeId("gallPeters");
28+
29+
// Show the lat and lng under the mouse cursor.
30+
const coordsDiv = document.getElementById("coords") as HTMLElement;
31+
32+
innerMap.addListener("mousemove", (event: google.maps.MapMouseEvent) => {
33+
coordsDiv.textContent =
34+
"lat: " +
35+
Math.round(event.latLng!.lat()) +
36+
", " +
37+
"lng: " +
38+
Math.round(event.latLng!.lng());
39+
});
40+
41+
// Add some markers to the map.
42+
innerMap.data.setStyle((feature) => {
43+
return {
44+
title: feature.getProperty("name") as string,
45+
optimized: false,
46+
};
47+
});
48+
innerMap.data.addGeoJson(cities);
49+
}
50+
51+
let gallPetersMapType;
52+
53+
function initGallPeters() {
54+
const GALL_PETERS_RANGE_X = 800;
55+
const GALL_PETERS_RANGE_Y = 512;
56+
57+
// Fetch Gall-Peters tiles stored locally on our server.
58+
gallPetersMapType = new google.maps.ImageMapType({
59+
getTileUrl: function (coord, zoom) {
60+
const scale = 1 << zoom;
61+
62+
// Wrap tiles horizontally.
63+
const x = ((coord.x % scale) + scale) % scale;
64+
65+
// Don't wrap tiles vertically.
66+
const y = coord.y;
67+
68+
if (y < 0 || y >= scale) return "";
69+
70+
return (
71+
"gall-peters_" +
72+
zoom +
73+
"_" +
74+
x +
75+
"_" +
76+
y +
77+
".png"
78+
);
79+
},
80+
tileSize: new google.maps.Size(GALL_PETERS_RANGE_X, GALL_PETERS_RANGE_Y),
81+
minZoom: 0,
82+
maxZoom: 1,
83+
name: "Gall-Peters",
84+
});
85+
86+
// Describe the Gall-Peters projection used by these tiles.
87+
gallPetersMapType.projection = {
88+
fromLatLngToPoint: function (latLng) {
89+
const latRadians = (latLng.lat() * Math.PI) / 180;
90+
return new google.maps.Point(
91+
GALL_PETERS_RANGE_X * (0.5 + latLng.lng() / 360),
92+
GALL_PETERS_RANGE_Y * (0.5 - 0.5 * Math.sin(latRadians))
93+
);
94+
},
95+
fromPointToLatLng: function (point, noWrap) {
96+
const x = point.x / GALL_PETERS_RANGE_X;
97+
const y = Math.max(0, Math.min(1, point.y / GALL_PETERS_RANGE_Y));
98+
99+
return new google.maps.LatLng(
100+
(Math.asin(1 - 2 * y) * 180) / Math.PI,
101+
-180 + 360 * x,
102+
noWrap
103+
);
104+
},
105+
};
106+
}
107+
108+
// GeoJSON, describing the locations and names of some cities.
109+
const cities = {
110+
type: "FeatureCollection",
111+
features: [
112+
{
113+
type: "Feature",
114+
geometry: { type: "Point", coordinates: [-87.65, 41.85] },
115+
properties: { name: "Chicago" },
116+
},
117+
{
118+
type: "Feature",
119+
geometry: { type: "Point", coordinates: [-149.9, 61.218] },
120+
properties: { name: "Anchorage" },
121+
},
122+
{
123+
type: "Feature",
124+
geometry: { type: "Point", coordinates: [-99.127, 19.427] },
125+
properties: { name: "Mexico City" },
126+
},
127+
{
128+
type: "Feature",
129+
geometry: { type: "Point", coordinates: [-0.126, 51.5] },
130+
properties: { name: "London" },
131+
},
132+
{
133+
type: "Feature",
134+
geometry: { type: "Point", coordinates: [28.045, -26.201] },
135+
properties: { name: "Johannesburg" },
136+
},
137+
{
138+
type: "Feature",
139+
geometry: { type: "Point", coordinates: [15.322, -4.325] },
140+
properties: { name: "Kinshasa" },
141+
},
142+
{
143+
type: "Feature",
144+
geometry: { type: "Point", coordinates: [151.207, -33.867] },
145+
properties: { name: "Sydney" },
146+
},
147+
{
148+
type: "Feature",
149+
geometry: { type: "Point", coordinates: [0, 0] },
150+
properties: { name: "0°N 0°E" },
151+
},
152+
],
153+
};
154+
155+
initMap();
156+
// [END maps_map_projection_simple]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@js-api-samples/map-projection-simple",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "tsc && bash ../jsfiddle.sh map-projection-simple && bash ../app.sh map-projection-simple && bash ../docs.sh map-projection-simple && npm run build:vite --workspace=. && bash ../dist.sh map-projection-simple",
6+
"test": "tsc && npm run build:vite --workspace=.",
7+
"start": "tsc && vite build --base './' && vite",
8+
"build:vite": "vite build --base './'",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
13+
}
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/* [START maps_map_projection_simple] */
7+
/*
8+
* Always set the map height explicitly to define the size of the div element
9+
* that contains the map.
10+
*/
11+
#map {
12+
height: 100%;
13+
}
14+
15+
/*
16+
* Optional: Makes the sample page fill the window.
17+
*/
18+
html,
19+
body {
20+
height: 100%;
21+
margin: 0;
22+
padding: 0;
23+
}
24+
25+
#coords {
26+
background-color: black;
27+
color: white;
28+
padding: 5px;
29+
}
30+
31+
/* [END maps_map_projection_simple] */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "esnext",
5+
"strict": true,
6+
"noImplicitAny": false,
7+
"lib": [
8+
"es2015",
9+
"esnext",
10+
"es6",
11+
"dom",
12+
"dom.iterable"
13+
],
14+
"moduleResolution": "Node",
15+
"jsx": "preserve"
16+
}
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/#map{height:100%}html,body{height:100%;margin:0;padding:0}#coords{background-color:#000;color:#fff;padding:5px}

dist/samples/map-projection-simple/dist/assets/index-DKpd9yxg.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)