{"action":"created","issue":{"url":"https://api.github.com/repos/ramnathv/rMaps/issues/107","repository_url":"https://api.github.com/repos/ramnathv/rMaps","labels_url":"https://api.github.com/repos/ramnathv/rMaps/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/ramnathv/rMaps/issues/107/comments","events_url":"https://api.github.com/repos/ramnathv/rMaps/issues/107/events","html_url":"https://github.com/ramnathv/rMaps/issues/107","id":148678213,"number":107,"title":"how to create two sets of markers in two layers","user":{"login":"imlearningr","id":17786308,"avatar_url":"https://avatars.githubusercontent.com/u/17786308?v=3","gravatar_id":"","url":"https://api.github.com/users/imlearningr","html_url":"https://github.com/imlearningr","followers_url":"https://api.github.com/users/imlearningr/followers","following_url":"https://api.github.com/users/imlearningr/following{/other_user}","gists_url":"https://api.github.com/users/imlearningr/gists{/gist_id}","starred_url":"https://api.github.com/users/imlearningr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imlearningr/subscriptions","organizations_url":"https://api.github.com/users/imlearningr/orgs","repos_url":"https://api.github.com/users/imlearningr/repos","events_url":"https://api.github.com/users/imlearningr/events{/privacy}","received_events_url":"https://api.github.com/users/imlearningr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-15T14:38:33Z","updated_at":"2016-05-04T04:44:28Z","closed_at":null,"body":"Hi @ramnathv ,\r\nThank you so much for your time and work in creating such a great package. I have been using it in a project to demonstrate job site and it empowers us to do something we haven't been able to before. I do have a question that I do not know how to tackle. I have read all the issues and your demonstrations on how to use the heatmap and routing plugins, but I am still a little uncertain. I hope you would help me out with some direction. \r\n\r\nokay, this is what I am trying to do. We have both the lat/long for center of job sites (centroid) and the individual locations within the job sites (raw points). So far, I have been successful in adding the centroid as markers on the map and use it in shiny. But now, I also want to add another sets of markers for the raw points, but I want it to be in a conditional layer so that when the map is first loaded, only the centroid would show but user can choose to show the raw points layer. I have read there are some layer control plugins but now sure how to incorporate them. Here is my code so far, but I was not successful in plotting two sets of markers, the second sets of markers just replaced the first one.\r\n\r\n`\r\n# load initial map\r\nmap <- Leaflet$new()\r\nmap$setView(c(mean(js_cluster_subset$GPS_LATITUDE), mean(js_cluster_subset$GPS_LONGITUDE)), zoom = 10)\r\nmap$tileLayer(provider = \"MapQuestOpen.OSM\")\r\nmap$set(height=750, width=1177)\r\nmap\r\n\r\n# create markers for job site centroid\r\njs_cluster_subset <- subset(js_cluster, VMC_VIN==\"1VRB31072E1000179\")\r\nfor (i in 1:dim(js_cluster_subset)[1]) {\r\n  map$marker(\r\n    c(js_cluster_subset$GPS_LATITUDE[i], js_cluster_subset$GPS_LONGITUDE[i]),\r\n    bindPopup = paste(paste0('Job Site #', js_cluster_subset$JOB_SITE_NO[i]),\r\n                      paste('Job Period:', js_cluster_subset$JOB_BEGIN_DATE[i], 'to', js_cluster_subset$JOB_END_DATE[i]),\r\n                      paste0('Engine Hour Used:', format(round(js_cluster_subset$ENGINE_HOUR[i],2), big.mark=\",\")), \r\n                      paste0('Fuel Used (gal):', format(round(js_cluster_subset$FUEL_USED_GAL[i],2), big.mark=\",\")), \r\n                      paste0('Total Distance Moved (ft.):', format(round(js_cluster_subset$DISTANCE_MOVED_FEET[i],2), big.mark=\",\")),\r\n                      sep=' | ')\r\n  )\r\n}\r\nmap\r\n\r\n# create markers for raw GPS points\r\njs_data_cluste_subset <- subset(js_data_cluster, VMC_VIN==\"1VRB31072E1000179\")\r\nfor (i in 1:dim(js_data_cluste_subset)[1]) {\r\n  map$marker(\r\n    c(js_data_cluste_subset$GPS_LATITUDE[i], js_data_cluste_subset$GPS_LONGITUDE[i])\r\n  )\r\n}\r\nmap\r\n`\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ramnathv/rMaps/issues/comments/216741703","html_url":"https://github.com/ramnathv/rMaps/issues/107#issuecomment-216741703","issue_url":"https://api.github.com/repos/ramnathv/rMaps/issues/107","id":216741703,"user":{"login":"rghertner","id":8419295,"avatar_url":"https://avatars.githubusercontent.com/u/8419295?v=3","gravatar_id":"","url":"https://api.github.com/users/rghertner","html_url":"https://github.com/rghertner","followers_url":"https://api.github.com/users/rghertner/followers","following_url":"https://api.github.com/users/rghertner/following{/other_user}","gists_url":"https://api.github.com/users/rghertner/gists{/gist_id}","starred_url":"https://api.github.com/users/rghertner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rghertner/subscriptions","organizations_url":"https://api.github.com/users/rghertner/orgs","repos_url":"https://api.github.com/users/rghertner/repos","events_url":"https://api.github.com/users/rghertner/events{/privacy}","received_events_url":"https://api.github.com/users/rghertner/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T04:44:28Z","updated_at":"2016-05-04T04:44:28Z","body":"+1 \r\nI'd like to add a polygon and a marker (actually, a circle whose size depends on a variable). Haven't figured out how to do this, but I think if I see a solution to your problem I can figure it out."}}