- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
新的 ggiraph 包非常适合让 ggplot2 响应用户的鼠标,没问题。
但是,我在使用 ggmap() 处理交互式/响应式(Reactive)经度和纬度点时遇到了问题。
交互性很好,当鼠标悬停在一个点上时我可以得到工具提示响应,但是当与 ggmap() 一起使用时,比例或轴似乎有问题。
下面的代码块提供了我正在尝试解决的问题的可重现示例,并且还链接了一些图像来说明我的意思。
首先安装所需的包,然后组成小的示例数据集,然后使用get_map() 函数下载所需的 map :
#Install required_packages:
required_packages <- c("ggmap", "ggplot2", "ggiraph")
new.packages <- required_packages[!(required_packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
#Load required_packages:
lapply(required_packages, require, character.only = TRUE)
#Make small example data set:
suburb<-c("BURNLEY","COLLINGWOOD","MALVERN","PRAHRAN","RICHMOND","SOUTH YARRA","ST KILDA","ST KILDA WEST","TOORAK","WINDSOR")
lon<-c(145.0176466,144.98815,145.036,144.998,144.998,144.989,144.982,144.9732,145.018,144.988)
lat<-c(-37.8299258, -37.8019,-37.857,-37.852,-37.823,-37.84,-37.864,-37.8604,-37.841,-37.854)
`Change 2005-2015 (%)`<-c(112, 120, 136, 127, 122, 115, 110, 146, 120, 128)
df<-data.frame(suburb, lon, lat, `Change 2005-2015 (%)`)
#Download map from google maps
SOUTH_YARRA <- get_map(location = 'South Yarra, Australia', zoom = 13, maptype="terrain")
现在我可以使用下面的代码创建静态 map 了:
ggmap(SOUTH_YARRA) +
geom_point(data = df,
aes(x =lon, y= lat, size=`Change 2005-2015 (%)`, colour = `Change 2005-2015 (%)`),
alpha=0.75) +
scale_colour_gradientn(colours=rainbow(5)) +
scale_radius (range = c(6, 12), trans = "identity", guide = "legend") +
ggtitle("Total change in Median \n House Price (%) from 2005-2015 \n")
here is the static map produced by the code above - no problem
但是,当我使用 ggiraph 的 geom_point_interactive() 使 map 中的点对用户的鼠标悬停使用react时,比例或轴出现问题:
#Try add reactivity using ggiraph's geom_point_interactive() instead of geom_point()
interactive_map<-ggmap(SOUTH_YARRA) +
geom_point_interactive(data = df,
aes(x =lon, y= lat, size=`Change 2005-2015 (%)`, colour = `Change 2005-2015 (%)`, tooltip=suburb, data_id = suburb),
alpha=0.75) +
scale_colour_gradientn(colours=rainbow(5)) +
scale_radius (range = c(6, 12), trans = "identity", guide = "legend") +
ggtitle("Total change in Median Melbourne \n House Price (%) from 2005-2015 \n")
ggiraph(code = {print(interactive_map)}, zoom_max = 5,
tooltip_offx = 20, tooltip_offy = -10,
hover_css = "fill:black;",
tooltip_opacity = 0.7)
我已经尝试将 maprange、extent 和 base_layer 参数更改为 ggmap() 函数,例如:
ggmap(SOUTH_YARRA, maprange=TRUE, extent = "panel", base_layer = ggplot(data = df, aes(x =lon, y= lat)))
然而这并没有帮助。 ggiraph 是一个很棒的包恕我直言,因为它是新的,所以在 stackoverflow 等方面还没有太多关于它的信息。非常感谢任何帮助!
最佳答案
这是 ggiraph 包中的一个错误,包维护者刚刚修复了它,请在此处查看 github 错误报告以获取更多详细信息:https://github.com/davidgohel/ggiraph/issues/32#issuecomment-257869888
关于R ggiraph with ggmap for interactive/reactive longitude and latitude points - scale or axis issue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40166761/
我在处理 Google map 时,发现了一个以前从未遇到过的奇怪错误:这是详细信息。 我试图在边界上放置两个标记,使用 latLngBounds = new LatLngBounds(mDestin
这个问题来 self 布置的家庭作业。您可以将存储系统基于以下三种格式之一: DD MM SS.S DD MM.MMM DD.DDDDDD 您想通过使用尽可能少的字节来最大化可以存储的数据量。 我的解
我想使用经度和纬度在 map 上覆盖机场之间的大圆弧。 我已经可以从初始和最终坐标中获得距离和方位,但现在我需要在曲线上生成要绘制的点。 我想要的是一个公式,它采用起点、终点和距离,并返回起点和终点之
谷歌地图以十进制表示法为我提供了位置的纬度和经度,如下所示: 38.203655,-76.113281 如何将它们转换为坐标(度、分、秒) 最佳答案 38.203655 是度的十进制值。有 60 分钟
是否有函数/算法允许我输入纬度和地球的大致轨道位置,以便我可以确定太阳升起的时间? IE 在冬天它会显示太阳在遥远的北半球只升起几个小时。 我做了一些基本的谷歌搜索,但没有找到太多,所以我想我可能需要
我的代码不起作用。我需要将数组的值与输入的值进行比较并返回纬度和经度值,以便在 map 上绘制该点,但只收到错误无法读取未定义的属性纬度。 var auto1 = [{"Latitude": 42.3
我正在试用 ionic native。获取权限成功,但之后报错cannot read property 'latitude' of undefined。 注意* 我使用的是 android 模拟器,而
我有一个经度和纬度,想将其转换为四元数,想知道如何做到这一点?我想使用它,因为我有一个应用程序可以将地球投影到一个球体上,我想从一个位置旋转到另一个位置。 最好的事物! 最佳答案 有一种不使用矩阵或向
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
我想弄清楚纬度/经度点是否包含在由代表地球上的点(也包括纬度/经度,按顺时针顺序)的顶点定义的多边形内。这对于可以映射到 2D lat/lon 空间的多边形来说是微不足道的。 这变得越来越困难的是圆形
在我的 HTML5 应用程序中,我使用 Google Map v3 并在 map 上添加了几个标记。放置新标记和更改图标很容易,但我希望能够构建类似于 Google Latitude 中使用的标记。这
这里有任何三角或 GPS 专家可以帮助我吗?我正在尝试创建一个地理空间边界框(矩形)计算,使用我检索到的以下方法返回最大纬度和经度。我为每个方位调用该方法一次:北、南、东和西。有了这四个值,我打算查询
关注 documentation 我试过查询 ContentResolver获取文件大小,如下所示: @Override protected void onActivityResult(int req
我的代码输入总是放在其他部分。这意味着 {location} 为空。 有什么建议吗? locManager = (LocationManager)getSystemService(Context.LO
我希望用户将信息输入到结构数组中,但却收到 4 个相同类型的错误,即: request for member 'locName' in something not a structure or uni
我正在尝试验证遵循以下模式的文本: 开头必须有文字“point(” 必须后跟最多 5 位小数的纬度数值(例如:42.12345) 后面必须跟逗号“,” 必须在其后跟一个最多保留 5 位小数的经度数值(
SELECT GROUP_CONCAT(TRIM(postmeta.meta_value) SEPARATOR ",") , SUBSTRING_INDEX(GROUP_CONCAT(TRI
我现在正在开发一个跟踪用户位置的应用程序。我希望这个应用程序即使不在任务列表中也能运行(双击主页按钮不显示它)。与 google latitude 一样,该应用程序不在后台运行。我认为该文档讨论的是当
这是我的代码 import 'package:flutter/material.dart'; import 'package:climate/services/location.dart'; impo
假设我有成百上千个 GPS 坐标、纬度和经度构成一个国家的边界。 我还有我当前位置的纬度和经度。 如何确定(使用 C#,Windows10 UWP 编程)我的位置是否在某个国家/地区的边界内? 例
我是一名优秀的程序员,十分优秀!