Skip to content

Commit

Permalink
fix map input bug, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Aug 6, 2024
1 parent 81cbcd3 commit 409ff48
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mapgl
Title: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' in R
Version: 0.1.2
Date: 2024-08-05
Date: 2024-08-06
Authors@R:
person(given = "Kyle", family = "Walker", email = "[email protected]", role = c("aut", "cre"))
Description: Provides an interface to the 'Mapbox GL JS' (<https://docs.mapbox.com/mapbox-gl-js/guides>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
4 changes: 2 additions & 2 deletions docs/articles/shiny.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ articles:
layers-overview: layers-overview.html
map-design: map-design.html
shiny: shiny.html
last_built: 2024-08-05T16:41Z
last_built: 2024-08-06T15:29Z
urls:
reference: https://walker-data.com/mapgl/reference
article: https://walker-data.com/mapgl/articles
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/htmlwidgets/mapboxgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
6 changes: 3 additions & 3 deletions inst/htmlwidgets/maplibregl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ HTMLWidgets.widget({
var center = map.getCenter();
var zoom = map.getZoom();

Shiny.onInputChange(el.id + '_zoom', zoom);
Shiny.onInputChange(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.onInputChange(el.id + '_bbox', {
Shiny.setInputValue(el.id + '_zoom', zoom);
Shiny.setInputValue(el.id + '_center', { lng: center.lng, lat: center.lat });
Shiny.setInputValue(el.id + '_bbox', {
xmin: bounds.getWest(),
ymin: bounds.getSouth(),
xmax: bounds.getEast(),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/shiny.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ A number of map events are built-in when working with **mapgl** in a Shiny sessi

- input\$*MAPID*\_zoom: The current zoom level of the map;

- input\$*MAPID*\_bounds: The bounding box of the visible extent of the map, named as `xmin`, `xmax`, `ymin`, and `ymax`.
- input\$*MAPID*\_bbox: The bounding box of the visible extent of the map, named as `xmin`, `xmax`, `ymin`, and `ymax`.

Visible features on the map can also be queried when clicked. Clicking the map in Shiny returns input\$*MAPID*\_feature_click, which gets you the layer ID, all of the column values for the clicked feature (accessible in `properties`), as well as the coordinates and time of the click.

Expand Down

0 comments on commit 409ff48

Please sign in to comment.