-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Mapbox-gl-geocoder v4 examples #8053
Merged
scottsfarley93
merged 15 commits into
publisher-production
from
mapbox-gl-geocoder-version4-examples
Apr 9, 2019
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8c6b7a6
add geocoder custom render example
0cbffbf
language localize example
7182303
Update marker demo to use built-in marker function
016e381
remove proximity bias for gl-geocoder example because this is now def…
7f9395f
update point from geocode demo to set custom marker color
9619aea
update examples to use new mapbox-gl-geocoder API options
3760ff9
lint new examples
17aff86
Update examples to gl-geocoder 4.0.0 api
e4624c5
Options should be added to the geocoder, not the map
b78debb
lint examples
18b15e5
remove templating syntax
696db7c
lint fixes
f1625ab
@katydecorah 's code review fixes
b147bd5
Merge branch 'mapbox-gl-geocoder-version4-examples' of github.com:map…
8f6ac8e
merge publisher-production upstream changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.0.0/mapbox-gl-geocoder.min.js'></script> | ||
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.0.0/mapbox-gl-geocoder.css' type='text/css' /> | ||
<style> | ||
.result{ | ||
font-style: italic; | ||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; | ||
color: gray; | ||
} | ||
</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, | ||
render: function(item){ | ||
// add a custom render function that shows an icon in the dropdown menu | ||
var maki = item.properties.maki || 'marker'; | ||
return `<span class='result'><img src='https://unpkg.com/@mapbox/[email protected]/icons/${marker}-11.svg'>${item.place_name}</span>` | ||
} | ||
}); | ||
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,13 @@ | ||
/*--- | ||
title: Add a custom render function to a geocoder | ||
description: >- | ||
Use the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
control to search for places using Mapbox Geocoding API, and render the matching | ||
places in a customized way. | ||
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); |
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,19 @@ | ||
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.0.0/mapbox-gl-geocoder.min.js'></script> | ||
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.0.0/mapbox-gl-geocoder.css' type='text/css' /> | ||
<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, | ||
language: 'de-DE' | ||
}); | ||
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: Localize the geocoder to a given language | ||
description: >- | ||
Localize the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
to set the UI language and improve result relevance in that language. | ||
tags: | ||
- geocoder | ||
pathname: /mapbox-gl-js/example/mapbox-gl-geocoder-with-language/ | ||
---*/ | ||
import Example from '../../components/example'; | ||
import html from './mapbox-gl-geocoder-with-language.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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning behind
draggable: true
? I get it shows options you can pass in, but I'm not sure if this makes sense as a default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entirely as an example of being able to pass in options. Perhaps just the
color
option would suffice as an illustrative example.