Leaflet / Leaflet.markercluster

Marker Clustering plugin for Leaflet
MIT License
3.95k stars 996 forks source link

Can't run Leaflet.markercluster with Shiny-server #371

Closed withr closed 8 years ago

withr commented 10 years ago

Hi Danzel, First, thanks a lot for creating this amazing package!! I found many sites are using it after I have chosen it. Today, I spent almost a whole day to integrate it with Shiny-server, which is a server for hosting R based application. In my app, I used rCharts (a R package which support creating Leaflet map) for its Leaflet class. https://github.com/ramnathv/rCharts/blob/master/R/Leaflet.R. Everything goes fine, except markercluaster doesn't work.

I used the data and code in: http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html, and got error message said: TypeError: undefined is not a function

I run the following code in Chrome's console: var markers = L.markerClusterGroup();
for (var i = 0; i < addressPoints.length; i++) { var a = addressPoints[i]; var title = a[2]; var marker = L.marker(new L.LatLng(a[0], a[1]), { title: title }); marker.bindPopup(title); markers.addLayer(marker); } and there is no error message.
But when run: map.addLayer(markers); I will get that error the first time, but not at the second time (however, still can't find the cluster markers).

Here is the address of my app: http://188.226.199.99/shiny-map

Any kind of help will be greatly appreciated.

Regards!

danzel commented 10 years ago

Run it under the javascript debugger and see what is undefined. You should be able to figure out what to do from there. You probably aren't including something you need to.

MarcBanc commented 10 years ago

var tNormM = L.tileLayer.chinaProvider('TianDiTu.Normal.Map', {maxZoom:18,minZoom:4}); L.tileLayer.chinaProvider === undefined and you call it as function so its throws error.

Hope it helps.

withr commented 10 years ago

@FalloutPL Sorry for my mistake (I changed some files today, and you happen to visit the website at that time). Now, I have corrected all files. please have a look.

withr commented 10 years ago

@danzel I guess I have everything included, because I can run it without Shiny-server, I guess may some leaflet functions, or variables were blocked by shiny.js,

MarcBanc commented 10 years ago

@withr I dont think its good place for that. Contact me by marcin.net[at]gmail.com if u need help.