Yandex Maps Api示例不起作用

循环的

我想在伊斯坦布尔的两点之间找到一条路线。为此,我尝试运行一个简单的代码,代码取自本指南但是此代码不起作用。我无法查看路线或地图。我的代码在这里。

<title>Quick start. Publishing an interactive map on a page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
<script src="http://yandex.st/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

    var ymap;
    ymaps.ready(function(){ 
        ymap = new ymaps.Map ("map", {
            center: [41.01771, 28.968484],
            zoom: 10,
            controls: ['zoomControl', 'typeSelector',
                       'geolocationControl', 'trafficControl',
                       'fullscreenControl'] 
        });

        ymaps.route([
            'Maltepe',
            'Kartal'
        ]).then(function (route){
            ymap.geoObjects.add(route);
            }, function(error){
               alert("Ошибка. " + error.status +
                     ":" + error.message);
            }
        );

    });

</script>
巴拉兹

示例中的代码是正确的。这是需要修复的页面。您必须在页面的HTML中添加适当位置/大小的DIV元素。该元素的ID(“地图”)作为第一个参数传递给构造函数new ymaps.Map

这是一个简单的HTML和CSS代码:

的HTML

<script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<div id="map"></div>

CSS:

body {
    height: 100%;
}
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

我为您创建了一个实时示例,请参见此小提琴

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Yandex Maps API中设置标记图标

Javascript和异步问题(使用yandex maps API建立距离矩阵)

Maps API发行密钥不起作用

为什么maps.yandex.com加载速度太慢?

MapControl显示具有偏移的Yandex Maps切片

Google Maps API V3-isLocationOnEdge()不起作用

Maps API icon.scaledSize不起作用

Azure Maps REST API链接不起作用

Google Maps API:标记链接不起作用

用于地理编码的Maps API密钥不起作用

用ajax调用Google Maps Api不起作用

发布版本中的Google Maps API Key不起作用

@react-google-maps/api <GoogleMap> onClick 不起作用

Yandex Weather API中禁止使用403

Google Maps Snap to road demo不起作用| Google Maps API错误:MissingKeyMapError

Google Maps的样式器不起作用?

Google Maps componentRestrictions不起作用

React Native Maps - showsUserLocation 不起作用

Google Maps iframe缩放不起作用

由于自定义图像,Google Maps API v3 多个标记不起作用?

Google Maps Android Api V2行驶路线不起作用

Google Maps Fusion Table API SQL“ LIKE”命令不起作用

Codeigniter Google Maps API V3地理编码不起作用

我的Google Maps api密钥虽然可以快速运行但在python中不起作用

Google Maps API didDrag、didBeginDragging、didEndDragging 功能不起作用

Google Maps Api 3-可见标记上的fitBounds不起作用

查询Fusion Tables在Google Maps JS API v3上不起作用

相同的Google Maps API代码在其他网站上不起作用

Google Maps API多边形中的fillColor不起作用