- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试实现 SimpleWeather插入地理定位。我尝试了这段代码,但它只显示按钮。我尝试了没有地理定位的示例,它工作正常,而且我的浏览器与地理定位功能兼容。
我正在 Tomcat 服务器中部署该文件,有什么帮助吗?
我也收到此控制台错误:
Uncaught TypeError: $.simpleWeather is not a function
<html>
<head>
<title>Weather</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/2.5.0/jquery.simpleWeather.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" charset="utf-8"></script>
</head>
<body>
<div id="weather"></div>
<button class="js-geolocation" style="display: none;">Use Your Location</button>
<script>
if ("geolocation" in navigator) {
$('.js-geolocation').show();
} else {
$('.js-geolocation').hide();
}
/* Where in the world are you? */
$('.js-geolocation').on('click', function() {
navigator.geolocation.getCurrentPosition(function(position) {
loadWeather(position.coords.latitude+','+position.coords.longitude); //load weather using your lat/lng coordinates
});
});
$(document).ready(function() {
loadWeather('Seattle',''); //@params location, woeid
});
function loadWeather(location, woeid) {
$.simpleWeather({
location: location,
woeid: woeid,
unit: 'f',
success: function(weather) {
html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
html += '<li class="currently">'+weather.currently+'</li>';
html += '<li>'+weather.alt.temp+'°C</li></ul>';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
}
</script>
</body>
</html>
最佳答案
您在 codepen 上提供的代码不包含 simpleWheather 插件。将其添加到 html 中:
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.0.2/jquery.simpleWeather.min.js"></script>
关于javascript - SimpleWeather 与地理定位不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30079232/
我正在尝试实现 SimpleWeather插入地理定位。我尝试了这段代码,但它只显示按钮。我尝试了没有地理定位的示例,它工作正常,而且我的浏览器与地理定位功能兼容。 我正在 Tomcat 服务器中部署
我一直在搞乱这个插件:http://jsfiddle.net/a4hbL/2064/ 每次满足条件时,我都会尝试使用 JQuery 显示文本:如果外面阳光明媚,则打印“It's Sunny”,如果下雪
我正在 asp.net 页面上使用 SimpleWeather jquery 插件,它工作正常。 https://github.com/monkeecreate/jquery.simpleWeathe
我想在我的网站上使用 simpleweatherjs 显示天气,但这对我不起作用。有人可以告诉我我做错了什么吗?页面是空白的。如果我,例如在 $.simpleWeather({...}); 行之前pu
我正在尝试使用 simpleweather js 制作一个天气应用程序。我已经成功地让应用程序显示我当前位置的天气,但我不确定如何让天气图标显示在温度旁边。任何帮助将不胜感激。这是我的代码笔:http
这个问题在这里已经有了答案: Check if Internet Connection Exists with jQuery? [duplicate] (9 个回答) 关闭 8 年前。
这对我来说非常挑剔,但我想将当前天气状态的大写字母更改为小写。大部分多云到大部分多云。另外我将如何设计文本样式?我以前从未在 jquery 中使用过 html。 html = ' It is curr
我正在使用这个插件:Simple Weather在我的网站上将天气绑定(bind)到我正在构建的简单小部件中。 我需要做的就是显示邮政编码中更深入的位置。目前,如果我在源代码中控制台记录“结果”对象,
我正在使用 weather.js ,我在我的 html 文件中包含了必要的导入: 并放入显示天气的html标签: 稍后我将 javascript: Weather.getCurrent('
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我是一名优秀的程序员,十分优秀!