Skip to content
Merged
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
40 changes: 40 additions & 0 deletions samples/layer-data-quakes-red/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Google Maps JavaScript Sample

This sample is generated from @googlemaps/js-samples located at
https://github.com/googlemaps-samples/js-api-samples.

## Setup

### Before starting run:

`npm i`

### Run an example on a local web server

`cd samples/layer-data-quakes-red`
`npm start`

### Build an individual example

`cd samples/layer-data-quakes-red`
`npm run build`

From 'samples':

`npm run build --workspace=layer-data-quakes-red/`

### Build all of the examples.

From 'samples':

`npm run build-all`

### Run lint to check for problems

`cd samples/layer-data-quakes-red`
`npx eslint index.ts`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
23 changes: 23 additions & 0 deletions samples/layer-data-quakes-red/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright 2019 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_layer_data_quakes_red] -->
<html>
<head>
<title>Simple Data Layer: Earthquakes</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>

<!-- prettier-ignore -->
<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))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</head>
<body>
<gmp-map center="20,-160" zoom="2"></gmp-map>
</body>
</html>
<!-- [END maps_layer_data_quakes_red] -->
53 changes: 53 additions & 0 deletions samples/layer-data-quakes-red/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_layer_data_quakes_red]
let innerMap;

async function initMap() {
(await google.maps.importLibrary("maps")) as google.maps.MapsLibrary;

const mapElement = document.querySelector(
"gmp-map"
) as google.maps.MapElement;

innerMap = mapElement.innerMap;

// Get the earthquake data (JSONP format)
// This feed is a copy from the USGS feed, you can find the originals here:
// http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
const script = document.createElement("script");

script.setAttribute(
"src",
"quakes.geo.json"
);

document.getElementsByTagName("head")[0].appendChild(script);

// Add a basic style.
innerMap.data.setStyle((feature) => {
const mag = Math.exp(parseFloat(feature.getProperty("mag") as string)) * 0.1;
return /** @type {google.maps.Data.StyleOptions} */ {
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: mag,
fillColor: "#f00",
fillOpacity: 0.35,
strokeWeight: 0,
},
};
});
}

// Defines the callback function referenced in the jsonp file.
function eqfeed_callback(data: any) {
innerMap.data.addGeoJson(data);
}

window.eqfeed_callback = eqfeed_callback;
initMap();
// [END maps_layer_data_quakes_red]
14 changes: 14 additions & 0 deletions samples/layer-data-quakes-red/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@js-api-samples/layer-data-quakes-red",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh layer-data-quakes-red && bash ../app.sh layer-data-quakes-red && bash ../docs.sh layer-data-quakes-red && npm run build:vite --workspace=. && bash ../dist.sh layer-data-quakes-red",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {

}
}
1,021 changes: 1,021 additions & 0 deletions samples/layer-data-quakes-red/public/quakes.geo.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions samples/layer-data-quakes-red/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_layer_data_quakes_red] */
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
gmp-map {
height: 100%;
}

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

/* [END maps_layer_data_quakes_red] */
17 changes: 17 additions & 0 deletions samples/layer-data-quakes-red/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"strict": true,
"noImplicitAny": false,
"lib": [
"es2015",
"esnext",
"es6",
"dom",
"dom.iterable"
],
"moduleResolution": "Node",
"jsx": "preserve"
}
}
40 changes: 40 additions & 0 deletions samples/layer-data-quakes-simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Google Maps JavaScript Sample

This sample is generated from @googlemaps/js-samples located at
https://github.com/googlemaps-samples/js-api-samples.

## Setup

### Before starting run:

`npm i`

### Run an example on a local web server

`cd samples/layer-data-quakes-simple`
`npm start`

### Build an individual example

`cd samples/layer-data-quakes-simple`
`npm run build`

From 'samples':

`npm run build --workspace=layer-data-quakes-simple/`

### Build all of the examples.

From 'samples':

`npm run build-all`

### Run lint to check for problems

`cd samples/layer-data-quakes-simple`
`npx eslint index.ts`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
23 changes: 23 additions & 0 deletions samples/layer-data-quakes-simple/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<!--
@license
Copyright 2019 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_layer_data_quakes_simple] -->
<html>
<head>
<title>Default Data Layer: Earthquakes</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>

<!-- prettier-ignore -->
<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))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</head>
<body>
<gmp-map center="20,-160" zoom="3"></gmp-map>
</body>
</html>
<!-- [END maps_layer_data_quakes_simple] -->
40 changes: 40 additions & 0 deletions samples/layer-data-quakes-simple/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_layer_data_quakes_simple]
let innerMap;
let earthquakeData;

async function initMap() {
(await google.maps.importLibrary("maps")) as google.maps.MapsLibrary;

const mapElement = document.querySelector(
"gmp-map"
) as google.maps.MapElement;

innerMap = mapElement.innerMap;

// Get the earthquake data (JSONP format)
// This feed is a copy from the USGS feed, you can find the originals here:
// http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
const script = document.createElement("script");

script.setAttribute(
"src",
"quakes.geo.json"
);

document.getElementsByTagName("head")[0].appendChild(script);
}

// Defines the callback function referenced in the jsonp file.
function eqfeed_callback(data: any) {
innerMap.data.addGeoJson(data);
}

window.eqfeed_callback = eqfeed_callback;
initMap();
// [END maps_layer_data_quakes_simple]
14 changes: 14 additions & 0 deletions samples/layer-data-quakes-simple/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@js-api-samples/layer-data-quakes-simple",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh layer-data-quakes-simple && bash ../app.sh layer-data-quakes-simple && bash ../docs.sh layer-data-quakes-simple && npm run build:vite --workspace=. && bash ../dist.sh layer-data-quakes-simple",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {

}
}
Loading