Skip to content

Instantly share code, notes, and snippets.

@sushantjha8
Forked from donmccurdy/.block
Created July 26, 2019 09:42
Show Gist options
  • Select an option

  • Save sushantjha8/2e2b7fd7b2f9eb7da2ea0937bcbb477f to your computer and use it in GitHub Desktop.

Select an option

Save sushantjha8/2e2b7fd7b2f9eb7da2ea0937bcbb477f to your computer and use it in GitHub Desktop.

Revisions

  1. @donmccurdy donmccurdy revised this gist Apr 15, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -62,7 +62,7 @@
    </script>

    <!-- NOTE: The 'key' parameter should be replaced with your Google Maps API Key. -->
    <script src="https://maps.googleapis.com/maps/api/js?callback=initMap&key=AIzaSyCYcTO2uK_yjgU8Aa3OTplYwBEMfxIIp4w"></script>
    <script src="https://maps.googleapis.com/maps/api/js?callback=initMap&key=AIzaSyDaoLdV31Y5ls8ABBpuAQt9t8RzMDfOMiM"></script>

    </body>
    </html>
  2. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -68,7 +68,7 @@ map.setMapTypeId(layerID);

    A complete example is shown in `index.html`.

    Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes).
    Further documentation at [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes).

    ## License

  3. @donmccurdy donmccurdy renamed this gist Apr 11, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -72,6 +72,6 @@ Further documentation: [Google Maps JS API: Image Map Types](https://developers.

    ## License

    Code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
    Sample code by Google, under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).

    Watercolor map data created by [Stamen](http://maps.stamen.com/), licensed [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
    Watercolor map tiles by [Stamen Design](http://stamen.com/), under [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
  5. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -66,7 +66,9 @@ map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    ```

    A complete example is shown in `index.html`. Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)
    A complete example is shown in `index.html`.

    Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes).

    ## License

  6. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -66,7 +66,7 @@ map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    ```

    Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)
    A complete example is shown in `index.html`. Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)

    ## License

  7. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,13 @@ An example showing how to use custom tiles with the [Google Maps JS API](https:/
    <div id="map"></div>
    ```

    * **(6)** Create a new map, attached to the element.
    * **(6)** Add the Maps API script to your page:

    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```

    * **(7)** Create a new map, attached to the element.

    ```javascript
    var mapEl = document.querySelector('#map');
    @@ -24,13 +30,7 @@ var map = new google.maps.Map(mapEl, {
    });
    ```

    * **(7)** As shown in `index.html`, add the Maps API script to your page:

    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```

    * **(8)** In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.
    * **(8)** Replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.

    Create a new tile layer using this URL:

  8. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,11 @@ An example showing how to use custom tiles with the [Google Maps JS API](https:/
    <div id="map"></div>
    ```

    * **(6)** Create a new map in this element.
    * **(6)** Create a new map, attached to the element.

    ```javascript
    var mapEl = document.querySelector('#map');
    map = new google.maps.Map(mapEl, {
    var map = new google.maps.Map(mapEl, {
    center: new google.maps.LatLng(39.8282, -98.5795),
    zoom: 5
    });
  9. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -35,8 +35,13 @@ map = new google.maps.Map(mapEl, {
    Create a new tile layer using this URL:

    ```javascript
    // Replace this with your URL.
    var TILE_URL = 'https://example.com/sample/{z}_{x}_{y}.jpg';

    // Name the layer anything you like.
    var layerID = 'my_custom_layer';

    // Create a new ImageMapType layer.
    var layer = new google.maps.ImageMapType({
    name: layerID,
    getTileUrl: function(coord, zoom) {
    @@ -56,6 +61,7 @@ var layer = new google.maps.ImageMapType({
    * **(9)** Add the new tile layer to your map:

    ```javascript
    // Register the new layer, then activate it.
    map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    ```
  10. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    ```

    Further documentation: [Image Map Types • Google Maps JS API](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)
    Further documentation: [Google Maps JS API: Image Map Types](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)

    ## License

  11. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,17 +4,17 @@ An example showing how to use custom tiles with the [Google Maps JS API](https:/

    ## Instructions

    * (1) Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    * (2) Create a new project.
    * (3) In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    * (4) Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. Save this key for later. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    * (5) Add an element to the page, where the map should appear.
    * **(1)** Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    * **(2)** Create a new project.
    * **(3)** In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    * **(4)** Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. Save this key for later. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    * **(5)** Add an element to the page, where the map should appear.

    ```html
    <div id="map"></div>
    ```

    * (6) Create a new map in this element.
    * **(6)** Create a new map in this element.

    ```javascript
    var mapEl = document.querySelector('#map');
    @@ -24,13 +24,13 @@ map = new google.maps.Map(mapEl, {
    });
    ```

    * (7) As shown in `index.html`, add the Maps API script to your page:
    * **(7)** As shown in `index.html`, add the Maps API script to your page:

    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```

    * (8) In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.
    * **(8)** In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.

    Create a new tile layer using this URL:

    @@ -53,7 +53,7 @@ var layer = new google.maps.ImageMapType({
    });
    ```

    * (9) Add the new tile layer to your map:
    * **(9)** Add the new tile layer to your map:

    ```javascript
    map.mapTypes.set(layerID, layer);
  12. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    # Custom tiles in Google Maps

    An example showing how to use custom tiles with the [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/).

    [▶️ Live demo](http://bl.ocks.org/donmccurdy/raw/1d3998a37c73e9435b5503e5f37457be)
  13. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 2 changed files with 10 additions and 9 deletions.
    1 change: 1 addition & 0 deletions .block.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    license: apache-2.0
    18 changes: 9 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,17 +6,17 @@ An example showing how to use custom tiles with the [Google Maps JS API](https:/

    ## Instructions

    1. Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    2. Create a new project.
    3. In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    4. Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. Save this key for later. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    5. Add an element to the page, where the map should appear.
    * (1) Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    * (2) Create a new project.
    * (3) In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    * (4) Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. Save this key for later. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    * (5) Add an element to the page, where the map should appear.

    ```html
    <div id="map"></div>
    ```

    6. Create a new map in this element.
    * (6) Create a new map in this element.

    ```javascript
    var mapEl = document.querySelector('#map');
    @@ -26,13 +26,13 @@ map = new google.maps.Map(mapEl, {
    });
    ```

    7. As shown in `index.html`, add the Maps API script to your page:
    * (7) As shown in `index.html`, add the Maps API script to your page:

    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```

    8. In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.
    * (8) In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.

    Create a new tile layer using this URL:

    @@ -55,7 +55,7 @@ var layer = new google.maps.ImageMapType({
    });
    ```

    7. Add the new tile layer to your map:
    * (9) Add the new tile layer to your map:

    ```javascript
    map.mapTypes.set(layerID, layer);
  14. @donmccurdy donmccurdy revised this gist Apr 11, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -66,4 +66,6 @@ Further documentation: [Image Map Types • Google Maps JS API](https://develope

    ## License

    Code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). Watercolor data was created by [Stamen](http://maps.stamen.com/), licensed [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
    Code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).

    Watercolor map data created by [Stamen](http://maps.stamen.com/), licensed [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
  15. @donmccurdy donmccurdy revised this gist Apr 10, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Custom tiles in Google Maps

    An example showing how to use custom tiles with the [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/).

    [▶️ Live demo](http://bl.ocks.org/donmccurdy/raw/1d3998a37c73e9435b5503e5f37457be)
  16. @donmccurdy donmccurdy revised this gist Apr 10, 2017. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,8 @@
    Custom tiles in Google Maps
    =========================

    An example showing how to use custom tiles with the [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/).

    [▶️ Live demo](http://bl.ocks.org/donmccurdy/raw/1d3998a37c73e9435b5503e5f37457be)

    Instructions
    ------------
    ## Instructions

    1. Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    2. Create a new project.
    @@ -28,10 +24,8 @@ map = new google.maps.Map(mapEl, {
    });
    ```


    7. As shown in `index.html`, add the Maps API script to your page:


    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```
    @@ -68,7 +62,6 @@ map.setMapTypeId(layerID);

    Further documentation: [Image Map Types • Google Maps JS API](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)

    License
    -----------------
    ## License

    Code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). Watercolor data was created by [Stamen](http://maps.stamen.com/), licensed [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
  17. @donmccurdy donmccurdy revised this gist Apr 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@
    // Create a new map.
    map = new google.maps.Map(mapEl, {
    center: new google.maps.LatLng(39.8282, -98.5795),
    zoom: 5
    zoom: 4
    });

    // Create a tile layer, configured to fetch tiles from TILE_URL.
  18. @donmccurdy donmccurdy renamed this gist Apr 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-image-map-types.md → README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ Custom tiles in Google Maps

    An example showing how to use custom tiles with the [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/).

    [▶️ Live demo](https://google-map-types.glitch.me/)
    [▶️ Live demo](http://bl.ocks.org/donmccurdy/raw/1d3998a37c73e9435b5503e5f37457be)

    Instructions
    ------------
  19. @donmccurdy donmccurdy revised this gist Apr 10, 2017. 1 changed file with 68 additions and 0 deletions.
    68 changes: 68 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Demo</title>
    <style>
    /* styles */

    html, body {
    margin: 0;
    padding: 0;
    }

    #map {
    width: 100vw;
    height: 100vh;
    }
    </style>
    </head>
    <body>

    <div id="map"></div>

    <script>
    var TILE_URL = 'http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg';

    var map;
    var mapEl;
    var layer;
    var layerID = 'my-custom-layer';

    window.initMap = function() {
    // Select the element with id="map".
    mapEl = document.querySelector('#map');

    // Create a new map.
    map = new google.maps.Map(mapEl, {
    center: new google.maps.LatLng(39.8282, -98.5795),
    zoom: 5
    });

    // Create a tile layer, configured to fetch tiles from TILE_URL.
    layer = new google.maps.ImageMapType({
    name: layerID,
    getTileUrl: function(coord, zoom) {
    console.log(coord);
    var url = TILE_URL
    .replace('{x}', coord.x)
    .replace('{y}', coord.y)
    .replace('{z}', zoom);
    return url;
    },
    tileSize: new google.maps.Size(256, 256),
    minZoom: 1,
    maxZoom: 20
    });

    // Apply the new tile layer to the map.
    map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    };
    </script>

    <!-- NOTE: The 'key' parameter should be replaced with your Google Maps API Key. -->
    <script src="https://maps.googleapis.com/maps/api/js?callback=initMap&key=AIzaSyCYcTO2uK_yjgU8Aa3OTplYwBEMfxIIp4w"></script>

    </body>
    </html>
  20. @donmccurdy donmccurdy revised this gist Apr 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-image-map-types.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Instructions
    1. Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    2. Create a new project.
    3. In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    4. Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    4. Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. Save this key for later. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    5. Add an element to the page, where the map should appear.

    ```html
  21. @donmccurdy donmccurdy created this gist Apr 10, 2017.
    74 changes: 74 additions & 0 deletions google-image-map-types.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    Custom tiles in Google Maps
    =========================

    An example showing how to use custom tiles with the [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/).

    [▶️ Live demo](https://google-map-types.glitch.me/)

    Instructions
    ------------

    1. Sign into the [Google Cloud Platform Console](console.cloud.google.com), or create a new account.
    2. Create a new project.
    3. In the console, open: *Menu* (☰) → *API Manager**Library*. Select the *Google Maps JavaScript API* and choose *Enable*.
    4. Go to the *Credentials* page in the sidebar. Select *Create credentials**API key*. You may, optionally, add restrictions so that this new key may only be used on your domain(s).
    5. Add an element to the page, where the map should appear.

    ```html
    <div id="map"></div>
    ```

    6. Create a new map in this element.

    ```javascript
    var mapEl = document.querySelector('#map');
    map = new google.maps.Map(mapEl, {
    center: new google.maps.LatLng(39.8282, -98.5795),
    zoom: 5
    });
    ```


    7. As shown in `index.html`, add the Maps API script to your page:


    ```html
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    ```

    8. In a new script, replace the sample `TILE_URL` with your own, which should look (roughly) like: `https://example.com/sample/{z}_{x}_{y}.jpg`.

    Create a new tile layer using this URL:

    ```javascript
    var TILE_URL = 'https://example.com/sample/{z}_{x}_{y}.jpg';
    var layerID = 'my_custom_layer';
    var layer = new google.maps.ImageMapType({
    name: layerID,
    getTileUrl: function(coord, zoom) {
    console.log(coord);
    var url = TILE_URL
    .replace('{x}', coord.x)
    .replace('{y}', coord.y)
    .replace('{z}', zoom);
    return url;
    },
    tileSize: new google.maps.Size(256, 256),
    minZoom: 1,
    maxZoom: 20
    });
    ```

    7. Add the new tile layer to your map:

    ```javascript
    map.mapTypes.set(layerID, layer);
    map.setMapTypeId(layerID);
    ```

    Further documentation: [Image Map Types • Google Maps JS API](https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes)

    License
    -----------------

    Code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). Watercolor data was created by [Stamen](http://maps.stamen.com/), licensed [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).