googleVis
googleVis copied to clipboard
Cannot get custom marker set to work
Hi i am trying to get the custom marker set as described in https://developers.google.com/chart/interactive/docs/gallery/map#adding-multiple-marker-sets to work so that some points in my map use one marker icon while the rest use another marker icon...cant seem to get that to work..note that i can change the default marker icon..that works..so i added a new column to my data frame (doing this in R) called Marker (from what i understood from the html example) and it is correctly set to say some points have the Marker label as "pink" while the rest are set to "default"..but what i see is that all points end up using the "default" marker..
Here is my code...any help wold be very much appreciated.. have spent several hours on this...i am hoping this is supported...if not could you suggest an alternate way of doing this?
df = df %>% mutate(LatLong=gsub(",", ":", lat_long)) %>% mutate(Tip=paste("Times seen<BR>", "Count=", total, sep=""))%>% mutate(Marker=ifelse(total>300, "pink", "default"))
icons = "{'pink': {'normal': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Pink-icon.png', 'selected': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Right-Pink-icon.png'}, 'default': {'normal': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Azure-icon.png', 'selected': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Right-Azure-icon.png'}}"
M1 <- gvisMap(df, "LatLong", "Tip", options=list(showTip=TRUE, showLine=F, enableScrollWheel=TRUE, zoomLevel=2, mapType='terrain', useMapTypeControl=TRUE,width="900px",height="600px", icons=icons))
plot(M1)
You have to provide the icons via the options argument. Here is an example: https://github.com/mages/googleVis/issues/55
library(googleVis)
df <- data.frame(Adress=c("EC3M 7HA", "東京都新宿区北新宿2-21-1"),
Tip=c("Lloyd's", "Tokyo R User Group"))
plot(gvisMap(df, "Adress", "Tip",
options=list(mapType='normal',
icons="{'default': {'normal': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Azure-icon.png',
'selected': 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Right-Azure-icon.png'}
}", width=800, height=250)))
Thanks for the quick reply. I have provided the icons via the options argument, please see the code snippet i posted. I had looked at several examples, including the one in #55. My issue is that lets there are two points in the map and i want them both to have a different icon..i could not get that to work...if you could provide sample code for that then that would be awesome...thanks!
Oh, I see now. I don't think this feature is currently supported by gvisMap, as the column with the Marker variable would have to be specified as a separate argument, like locationvar and tipper.
Any workarounds..suggestions..really want this feature for a very important project...any help would be greatly appreciated.
I am sorry, but I haven't got the time to look into this in more detail. I think the underlying gvisMap function will require a bit of change to include a new variable for the marker. Feel free to have a go at this: https://github.com/mages/googleVis/blob/master/R/gvisMap.R