-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/mb-pages'
- Loading branch information
Showing
6 changed files
with
77 additions
and
8 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
69 changes: 69 additions & 0 deletions
69
docs/_posts/examples/3400-01-16-point-from-geocoder-result.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
layout: example | ||
category: example | ||
title: Set a point after Geocoder result | ||
description: 'Listen to the <code>geocoder.input</code> event from the <a target="_blank" href="https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-geocoder">Geocoder plugin</a> and place a point on the coordinate results.' | ||
tags: | ||
- plugins | ||
- mapbox-geocoding | ||
--- | ||
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v0.1.0/mapbox-gl-geocoder.js'></script> | ||
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v0.1.0/mapbox-gl-geocoder.css' type='text/css' /> | ||
<style> | ||
#geocoder-container { | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
margin-top: 10px; | ||
} | ||
|
||
#geocoder-container > div { | ||
min-width:50%; | ||
margin-left:25%; | ||
} | ||
</style> | ||
<div id='map'></div> | ||
<div id='geocoder-container'></div> | ||
|
||
<script> | ||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v8', | ||
center: [-79.4512, 43.6568], | ||
zoom: 13 | ||
}); | ||
|
||
var geocoder = new mapboxgl.Geocoder({ | ||
container: 'geocoder-container' // Optional. Specify a unique container for the control to be added to. | ||
}); | ||
|
||
map.addControl(geocoder); | ||
|
||
// After the map style has loaded on the page, add a source layer and default | ||
// styling for a single point. | ||
map.on('style.load', function() { | ||
map.addSource('single-point', { | ||
"type": "geojson", | ||
"data": { | ||
"type": "FeatureCollection", | ||
"features": [] | ||
} | ||
}); | ||
|
||
map.addLayer({ | ||
"id": "point", | ||
"source": "single-point", | ||
"type": "circle", | ||
"paint": { | ||
"circle-radius": 10, | ||
"circle-color": "#007cbf" | ||
} | ||
}); | ||
|
||
// Listen for the `geocoder.input` event that is triggered when a user | ||
// makes a selection and add a marker that matches the result. | ||
geocoder.on('geocoder.input', function(ev) { | ||
map.getSource('single-point').setData(ev.result.geometry); | ||
}); | ||
}); | ||
</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
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