Code Monkey home page Code Monkey logo

leafletr's People

Contributors

chgrl avatar francoisguillem avatar jhollist avatar ricschuster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leafletr's Issues

question on adding basemap form tile url

Hi,

I'm trying to add a basemap (an old map from the 19th century, that I warped using http://maps.nypl.org/warper/ ). the NYPL website provides the possibility to display the map as tile. Therefore I thought, I could use that as a basemap. Following the manual, I used this code:

addBaseMap(
name="nl1800",
title="nl1800",
url="http://maps.nypl.org/warper/maps/tile/7398/z/x/y.png",
options=list(
attribution='© <a href="http://maps.nypl.org/warper/", target=
"_blank">NYPL Map Warper'
)
)

Now I can see very very tiny images of the basemap layer out in a grid-like fashion, but what I wanted was to have this 'basemap' plotted underneath my map, just as is the case when you use mqstat as basemap. I've tried to add some of the options mentioned in the leaflet documentation, such as changing pixel size (to 1024) or zoom level, however, without any decent result. Could you please advise?

Best wishes,

Richard

toGeoJSON fails iff data.frame has 3 columns

Hi,

I've been working with leafletR to make some (very pretty) maps. The package does some very cool things, so thanks for all the great work on it. At the moment though, I think I just found a bug that may require a minor but important fix.

In cases where the user wishes to apply the function toGeoJSON to a data.frame, and that data.frame has exactly 3 columns (eg. lat, lon, and one other variable of interest), somewhere in the conversion, toGeoJSON seems to be dropping the name of the third variable. The result in my case is that the .geojson file now has one property called "", and this cannot be used to inform the style of the points on the map. You may be able to check out this problem for yourself by removing all but the first three columns of the quakes dataset used in the example.

Hopefully this should be an easy fix (potentially requiring the addition of a drop=FALSE somewhere in the code?). For now, the addition of a dummy fourth column seems to be doing the trick. But I thought I should pass this on to you so leafletR can keep being as wonderful as it can be.

Cheers,
Caitlin.

How to set color and radius at the same time?

First of all, this package is neat. Super simple to use.

Is there any way to create a style where I set the size of the points with one column of the data frame and the color with another column?

Leaflet is blank unless `incl.data = TRUE`

I'm having trouble displaying leaflet maps: I copy-paste'd the example code and the leaflet came up completely blank. I went back and set leaflet(data=data, incl.data=TRUE), and everything worked great. However, I would still like to be able to keep the data separate from the map.html. Anyway to fix this behavior?

P.S. Great package: really easy to use 👍

Failed to load resource: net::ERR_NAME_NOT_RESOLVED

Hi @chgrl,

I executed your provided code but I only get a gray screen. I can see the data points but not the map. The error in the browser is as follows: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
What am I doing wrong? I tried it with RStudio 1.1.453 and the docker image rocker/geospatial:3.4.2

Thanks in advance

Displaying leafletR generated map (html) in Shiny

chgrl, your package is way nicer at least for me, i am however still trying to figure out how to add the html generated by your package into Shiny. For now what I am looking for is too display the map (html) generated by leafletR in a Shiny and work just as if you had opened the map in a browser. It need not interact with any of the other pieces of the shiny code.
I am writing an R app and Shiny is real easy to use to get the other features I want.

If any of the community members have figured this out please let me know.

Thank you
-Andy

feature using basemap list as 'background' map no longer working?

Hi I seem to remember that I could create a basemap myself (e.g. based on a historical map) and overlay it on the mqsat map.

I think this feature is described on p.6 of the CRAN leafletR documentation, but it no longer seems to work:

example 1

map <- leaflet(base.map=list("osm", "mqsat", "tls"))
map

example 2

what I'm actually trying to do is to overlay a historic map of the Netherlands on the mqsat map of the world:

addBaseMap(
name="nl1800",
title="nl1800",
url="http://maps.nypl.org/warper/maps/tile/7398/{z}/{x}/{y}.png",
options=list(
attribution='© <a href="http://maps.nypl.org/warper/", target=
"_blank">NYPL Map Warper'
)
)

map <- leaflet(base.map=list("nl1800", "mqsat"))
map

Integration with Shiny

Hi - I haven't (yet!) tried to integrate leafletR into Shiny. Any caveat?

(thanks for the great package) Enzo

Problem with leaflet example

Hi,

When I run the following code from the leaflet, I often get an error.

park <- toGeoJSON(data=system.file(package="leafletR", "files", 
  "park_sk.zip"), dest=tempdir())

Error in function (type, msg, asError = TRUE)  : Empty reply from server 

When I have not the error, the generated file is often not a json but the following html document:

<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>

lexical error: invalid bytes in UTF8 string

Recently I ran an old program that I created six months ago, and encountered an UTF-8 encoding error. It was fine a couple of months ago.

Error in feed_push_parser(buf) :
lexical error: invalid bytes in UTF8 string.
properties": { "County": "Doña Ana County, New Mexico", "Pop
(right here) ------^

Travis Builds

Noticed you were having same issues with Travis and rgdal.

The yml that now works for me is:

language: r
warnings_are_errors: true
env:
global:
- NOT_CRAN=true
before_install: echo "options(repos = c(CRAN='http://cran.rstudio.com'))" > ~/.Rprofile

r_binary_packages:

  • rgdal

r_github_packages:

  • jimhester/covr

after_success:

  • Rscript -e 'library(covr); coveralls()'

The r_binary_packages does the trick!

toGeoJSON create a big size file, is it ok?

when I use
hp.dat<-toGeoJSON(data=hp_display[],lat.lon=c(6,5));
it create a big hp_display.geojson, it's about 800M.
why? is it wrong?

str(hp_display)
Classes ‘tbl_df’ and 'data.frame': 3035 obs. of 6 variables:
$ loupanmingcheng: chr "COCO蜜城" "SOLO黄金岁月" "TAHA时区" "UHN国际村" ...
$ fangchangeshu : int 49 31 140 51 7 1 46 23 235 424 ...
$ junjia : num 0.894 0.754 0.85 5.175 0.936 ...
$ city : chr "青岛" "青岛" "青岛" "北京" ...
$ longitude : num 120 120 120 116 117 ...
$ latitude : num 36.2 36.1 36.3 40 39.5 ...

Toner map

Hello, I try:

data(quakes)
dat <- toGeoJSON(data=quakes, dest=tempdir())

# create and view simple map
map <- leaflet(dat,incl.data = T,base.map = "toner")
map  # redirects to browseURL(map)

but I see the Watercolor map.

If I add these lines:

addBaseMap(name = "toner2",url = "http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png")
map <- leaflet(dat,incl.data = T,base.map = "toner2")
map  # redirects to browseURL(map)

It's OK.
I think, there are some error in url basemap.

¡Thanks!

Empty map with styleSingle

Dear Christian Graul,

First thank you for this very useful R package.
I found recently a problem with the marker in styleSingle even using the last version of leafletR (0.4). Here is a minimal example code I found in your answer to an other issue. It is strange because my code run well two month ago and that the resulting html file (I built two month ago) show now the same problem. I tried also with version 0.33 without success. Thus I think it is more a problem with maki but my skills are not sufficient to go further.

# When using marker
library(leafletR)
data(quakes)
dat1 <- toGeoJSON(data=quakes[1:10,], name="Quakes 1", dest=tempdir())
dat2 <- toGeoJSON(data=quakes[11:20,], name="Quakes 2", dest=tempdir())

# simple colored markers
sty1 <- styleSingle(marker="green") # only color

# markers with label, color and size
sty2 <- styleSingle(marker=c("triangle", "#E41A1C", "s"))

map <- leaflet(data=list(dat1, dat2), dest=tempdir(), style=list(sty1, sty2))
map


# Without using marker
library(leafletR)
data(quakes)
dat1 <- toGeoJSON(data=quakes[1:10,], name="Quakes 1", dest=tempdir())
dat2 <- toGeoJSON(data=quakes[11:20,], name="Quakes 2", dest=tempdir())

# simple colored markers
sty1 <- styleSingle(col="green") # only color

# markers with label, color and size
sty2 <- styleSingle(fill="#E41A1C")

map <- leaflet(data=list(dat1, dat2), dest=tempdir(), style=list(sty1, sty2))
map

Thanks again for this package.

leafletR does not support Chinese character well(GBK)?

As there are Chinese characters contained in popup, i don't know why they are showed as unrecognizable codes on the final html page. I have already change these characters into character string(originally factor).

This problem also appears when i use toGeoJSON function to get a .geojson file. All the Chinese characters are changed into number(such as 1 ,159 and so on )

Thank you~

Adding Markers, Circles, etc.

Hi Christian,
Is there a way to add Marker points, or other kind of interactive objects to the map, like with leaflet by Joe Cheng?
I like your library, because i can work with shp files, but i would love to add some markers to point out important issues of it.
Well, thanks in advance.
Greetings

Bug: leaflet() Zoom & center not working if parameter "data" is undefined

Is is possible for you to fix the the not working zoom & center parameters in case one does not define the parameter "data") ?

data(quakes)
dat <- toGeoJSON(data=quakes, dest=tempdir())

### Zoom & centering working
map <- leaflet(data=dat, dest=tempdir(),  center=c(-18.35, 179.75), zoom=10)

### Zoom & centering not working
map <- leaflet(dest=tempdir(),  center=c(-18.35, 179.75), zoom=10)

Using dots in names of the variables.

Eg.
map <- leaflet(data=GeoJSON, dest=getwd(),
base.map='osm',
popup=c('aaa', 'bbb', 'cc.cc.cc'),
incl.data=FALSE)

Afterwards, I couldn't see the map. Although, when I change dots to underlines - everything works fine:

colnames(sp@data) <- gsub('.', '_', colnames(sp@data))
GeoJSON <- toGeoJSON(data=sp, dest=getwd())
map <- leaflet(data=GeoJSON, dest=getwd(),
base.map='osm',
popup=c('aaa', 'bbb', 'cc_cc_cc'),
incl.data=FALSE)

Error if 'title' contains certain non alphanumeric characters

Hi,
The 'title' argument in 'leaflet' is used to build the directory and the file name. This leads to problems if the title string contains certain non alphanumeric characters:

library(leafletR)

# load example data (Fiji Earthquakes)
data(quakes)

# store data in GeoJSON file (just a subset here)
q.dat <- toGeoJSON(data=quakes[1:99,], dest=tempdir(), name="quakes")

# Generate non alphanumeric characters
# http://stackoverflow.com/a/25485971
ascii <- rawToChar(as.raw(0:127), multiple=TRUE)
m <- ascii[grepl('[[:punct:]]', ascii)]
m

x <- list()
for (i in seq_along(m)) {
  attempt = try({
    title <- paste("Fiji Earthquakes", m[i], "x")
    q.map_fail <- leaflet(data=q.dat, title = title, dest=tempdir())
  })
   if ("try-error" %in% class(attempt)) x[[i]] <- m[i]
}
unlist(x)
# [1] "\"" "*"  "/"  ":"  "<"  ">"  "?"  "\\" "|" 

Thanks for the package!
Patrick

Base maps need an update

"tls" (Thunderforest Landscape), "mqosm" (MapQuest OSM), "mqsat" (MapQuest Open Aerial) do not work anymore

styleGrad with mutliple layers

Appears to be a bug when trying to style one layer as graduated and one as single symbol (may exist for categories too, but I haven't tried that). Looks like the function that get's written to the html for the graduated symbol doesn't get output correctly. It is getting wrapped up as if it were JSON.

To repeat the problem:

data(quakes)
qks <- toGeoJSON(data=quakes, dest=tempdir())
qks2 <- toGeoJSON(data=quakes, dest=tempdir())
sty <- styleGrad(prop="mag", breaks=seq(4, 6.5, by=0.5), 
                 style.val=rev(heat.colors(5)), leg="Richter Magnitude")
sty2 <- styleSingle(col="red")
map <- leaflet(data=list(qks,qks2), dest=tempdir(), 
               title="Fiji Earthquakes", style=list(sty,sty2))

I may try to track this down myself and if I do will submit a PR. But thought you might want to know.

Map Layer showing as grey

Hi, When I run the example quakes code, the map opens up in a new browser and the legend, zoom buttoms and osm/open maps footer is showing but the whole map area is grey.

believe this is an issue with my office firewall etc as when I am off the network it works but I am wondering if there is any known way to tell leaflet to access my proxy.

thanks.

Change borders color

When making categorical map without changing colors for polygon borders - everything works.
sty <- styleGrad(prop='variable', breaks=seq(96, 104, 1), style.par='col',
style.val=brewer.pal(8, 'PuOr'), leg='Title')
But when I try to change border colors, everything change to that color:
sty <- styleGrad(prop='variable', breaks=seq(96, 104, 1), col=1, style.par='col',
style.val=brewer.pal(8, 'PuOr'), leg='Title')
as a result, every polygon is black (the same as borders).

Addin logos, watermarks or images to html maps

Hi Chistian,
I wonder if there's any option to add a watermaked image or logo to the html file rendered by the leaflet function. I mean, if it can render a rectangled image where the legend is, or the zoom-in-out buttons, then maybe there's a posibility to add a semy-transparent (controled by alpha attributes) logo or image.
Right now I'm using webshot to generate jpg and pdf files with my so needed logo, so I already use this option. But the difference would be that with an integrated logo in the html, there won't be any need to generate a separated image (pdf or jpg) to print the map, also with the option to print the map with a zoom-in-out
Thnks in advance your library is working truly fine so far.
Greetings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.