-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
1,552 additions
and
757 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// @flow | ||
|
||
import type {StyleSpecification} from '../../src/style-spec/types'; | ||
import {normalizeStyleURL} from '../../src/util/mapbox'; | ||
import { RequestManager } from '../../src/util/mapbox'; | ||
|
||
const requestManager = new RequestManager(); | ||
|
||
export default function fetchStyle(value: string | StyleSpecification): Promise<StyleSpecification> { | ||
return typeof value === 'string' ? | ||
fetch(normalizeStyleURL(value)).then(response => response.json()) : | ||
fetch(requestManager.normalizeStyleURL(value)).then(response => response.json()) : | ||
Promise.resolve(value); | ||
} |
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
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
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
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
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
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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div id='map'></div> | ||
|
||
<script> | ||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v9', | ||
zoom: 1 | ||
}); | ||
|
||
map.on('load', function() { | ||
// Add GeoJSON data | ||
map.addSource('source', { | ||
"type": "geojson", | ||
"data": { | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [[ | ||
[-30, -25], | ||
[-30, 35], | ||
[30, 35], | ||
[30, -25], | ||
[-30, -25] | ||
]] | ||
} | ||
} | ||
}); | ||
|
||
// Load an image to use as the pattern | ||
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/64px-Cat_silhouette.svg.png', function(err, image) { | ||
// Throw an error if something went wrong | ||
if (err) throw err; | ||
|
||
// Declare the image | ||
map.addImage('pattern', image); | ||
|
||
// Use it | ||
map.addLayer({ | ||
"id": "pattern-layer", | ||
"type": "fill", | ||
"source": "source", | ||
"paint": { | ||
"fill-pattern": "pattern" | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--- | ||
title: Add a pattern to a polygon | ||
description: Use [fill-pattern](https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern) to draw a polygon from a repeating image pattern. | ||
tags: | ||
- layers | ||
pathname: /mapbox-gl-js/example/fill-pattern/ | ||
---*/ | ||
import Example from '../../components/example'; | ||
import html from './fill-pattern.html'; | ||
export default Example(html); |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.3.0/mapbox-gl-geocoder.min.js'></script> | ||
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.3.0/mapbox-gl-geocoder.css' type='text/css' /> | ||
<style> | ||
.geocoder-dropdown-item{ | ||
padding: 5px | ||
} | ||
.geocoder-dropdown-icon{ | ||
margin-right: 10px; | ||
} | ||
.geocoder-dropdown-text{ | ||
color: #5a3fc0; | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: larger; | ||
} | ||
</style> | ||
<div id='map'></div> | ||
|
||
<script> | ||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v9', | ||
center: [-79.4512, 43.6568], | ||
zoom: 13 | ||
}); | ||
|
||
var geocoder = new MapboxGeocoder({ | ||
accessToken: mapboxgl.accessToken, | ||
types: 'poi', | ||
// see https://docs.mapbox.com/api/search/#geocoding-response-object for information about the schema of each response feature | ||
render: function(item) { | ||
// extract the item's maki icon or use a default | ||
var maki = item.properties.maki || 'marker'; | ||
return "<div class='geocoder-dropdown-item'><img class='geocoder-dropdown-icon' src='https://unpkg.com/@mapbox/maki@6.1.0/icons/" + maki + "-15.svg'><span class='geocoder-dropdown-text'>" + item.text + "</span></div>"; | ||
}, | ||
mapboxgl: mapboxgl | ||
}); | ||
map.addControl(geocoder); | ||
|
||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/*--- | ||
title: Use a custom render function with a geocoder | ||
description: >- | ||
Use a custom html rendering function with the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
to customize how the dropdown menu is displayed. | ||
tags: | ||
- geocoder | ||
pathname: /mapbox-gl-js/example/mapbox-gl-geocoder-custom-render/ | ||
---*/ | ||
import Example from '../../components/example'; | ||
import html from './mapbox-gl-geocoder-custom-render.html'; | ||
export default Example(html); |
Oops, something went wrong.