library(gplots) library(rjson) library(RgoogleMaps) library(RColorBrewer) tmp = fromJSON(file ="http://data.baltimorecity.gov/api/views/aivj-4x23/rows.json") m = lapply(tmp$data,function(x){c(x[[22]][[3]][1],x[[22]][[2]][1])}) m = matrix(unlist(m),ncol=2,byrow=T) gunViolations=apply(m,2,as.numeric) MyMap = GetMap.bbox(lonR = gunViolations[,1],latR=gunViolations[,2],destfile="~/Desktop/baltimore.png") ##bitmap(file="baltimoreGunViolations.png",res=600,height=4,width=4) pdf("baltimoreGunViolations.pdf",width=5,height=5) PlotOnStaticMap(MyMap,lat=gunViolations[,2],lon=gunViolations[,2],pch=19,cex=0) newxy = LatLon2XY.centered(MyMap, gunViolations[,2],gunViolations[,1],zoom=MyMap$zoom) points(newxy$newX,newxy$newY,bg="red",cex=0.35,pch=21) ### I got these locations from http://itouchmap.com/latlong.html locs=rbind(c(39.364273,-76.672748), c(39.357503,-76.621054), c(39.354427,-76.638383), c(39.341543,-76.615277), c(39.330581,-76.61961), c(39.333371,-76.632607), c(39.297512,-76.592889)) locs=LatLon2XY.centered(MyMap,locs[,1],locs[,2],zoom=MyMap$zoom) locNames <- c("MountWashington","Homeland","RolandPark","Guilford","Homewood","Hampden","JHMI") for(i in seq(along=locNames)){ text(locs$newX[i],locs$newY[i],bquote(bold(.(locNames[i]))),cex=0.65,col="darkblue") } dev.off()