question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Leaflet tiles not showing in web viewer

See original GitHub issue

Describe the bug

Leaflet tiles are not showing in the web viewer.

To Reproduce Steps to reproduce the behavior:

  1. Install and load leaflet
  2. Run leaflet %>% addTiles()
  3. The plot opens up in the web viewer, there are zoom controls, but no map. It is all grey.

Do you want to fix by self? (We hope your help!)

Yes

(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)

I’d love to help, but I don’t know where to get started.

(If related)setting.json

// R path for Linux
"r.rterm.linux": "/home/<user>/.local/bin/radian",

// R command line options (i.e: --vanilla)
"r.rterm.option": [],

// An optional encoding to pass to R when executing the file, i.e. 'source(FILE, encoding=ENCODING)'
"r.source.encoding": "UTF-8",

// Keeping focus when running
"r.source.focus": "editor",

// Use active terminal for all commands, rather than creating a new R terminal
"r.alwaysUseActiveTerminal": false,

// Use bracketed paste mode
"r.bracketedPaste": true,

// Enable R session watcher (experimental)
"r.sessionWatcher": true,

// Delay in milliseconds before sending each line to rterm (only applies if r.bracketedPaste is false)
"r.rtermSendDelay": 8,

Expected behavior A clear and concise description of what you expected to happen.

Screenshots

Here is what is looks like in VS Code:

image

Here is what is looks like in RStudio:

image

Environment (please complete the following information):

  • OS: Linux (Fedora 34)
  • VSCode Version: 1.56.2
  • R Version: 4.0.5
  • vscode-R version: 1.6.8

Additional context

When running a shiny application, the map renders just fine.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ElianHughcommented, Jul 31, 2021

Thanks! I should have a PR up tomorrow, which handles on-demand loading as well

1reaction
ElianHughcommented, Jul 28, 2021

I have the following in order to safely replace strings that could be parsed as URLs:

.replace(/(?<='|")\/\/[A-Za-z0-9./{}]*(?='|")/g, function(match): string {
                const matchNoTemplates = match
                    .replace(/{[A-Za-z0-9]}/g, 'a')
                    .replace(/(\/\/)/, 'https://');
                let isUrl: boolean;

                try {
                    isUrl = !!(new URL(matchNoTemplates));
                } catch (_) {
                    isUrl = false;
                }

                if (isUrl) {
                    return (match.replace(/\/\//, 'https://'));
                } else {
                    return (match);
                }
            })

This does the following:

  1. Match a string encapsulated by quotes, that starts with //
  2. Create a dummy string with templates removed and the beginning // replaced with https://
  3. Check if the dummy string can be used to create a new URL
  4. If it can be, replace the match’s // with https://, else return match

I have had this successfully work with loading leaflet() |> addTiles().

There is the route of going purely regex, but I was thinking that this route is safer for modifying the html body

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet Map not rendering in Rmarkdown, R Notebook ...
There is something wrong with the default tiles set. Try this: ... Just open the map in Browser instead of Viewer. The same...
Read more >
Tiles from gdal2tiles won't appear on leaflet map
Start first by not adding the OSM Tile Layer and make sure your own Tile Layer displays fine. Then you might be interested...
Read more >
WebView NOT showing map tiles via LeafLet - YouTube
This is a very simple solution to the problem of not showing map tiles using LeafLet via WebView in an Android or iOS...
Read more >
Map tiles not showing up properly on mobile web app
I am using leaflet with my jQuery Mobile app for mobile browsers, I am pretty new to this, and I have problem with...
Read more >
Problem when viewing html generated by Leaflet - General
I then go to Export->Save as Web Page to save it as a html. However, when open up the html, the Map tile...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found