高德地图根据经纬度查询目的地天气预报信息代码

代码语言:html

所属分类:其他

代码描述:高德地图根据经纬度查询目的地天气预报信息代码

代码标签: 高德 地图 经纬度 查询 目的地 天气 预报

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>天气预报查询</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
    <style type="text/css">
        html,body,#container{
            height:100%;
        }
        .weather{
            width:5rem;
            display:inline-block;
            padding-left:0.5rem;
        }
        .sharp{
            height: 1rem;
            width: 1rem;
            background-color: white;
            transform: rotateZ(45deg);
            box-shadow: 2px 2px 3px rgba(114, 124, 245, .5);
            position: inherit;
            margin-left: 10.5rem;
            margin-top: -6px;
        }
    </style>
</head>
<body>
<div id="container"></div>
<div class="info">
    <h4>预报天气</h4><hr>
    <p id='forecast'></p>
</div>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=243687cce3d5ac3f7a3b4bb90a97fda1"></script>
<script type="text/javascript">
    var map = new AMap.Map('container', {
        resizeEnable: true,
		center: [116.486409,39.921489],
        zoom: 12
    });
    AMap.plugin('AMap.Weather', function() {
        var weather = new AMap.Weather();
        //查询实时天气信息, 查询的城市到行政级别的城市,如朝阳区、杭州市
        weather.getLive('朝阳区', function(err, data) {
            if (!err) {
                var str = [];
                str.push('<h4 >实时天气' + '</h4><hr>');
                str.push('<p>城市/区:' + data.city + '</p>');
                str.push('<.........完整代码请登录后点击上方下载按钮下载查看

网友评论0