openlayers 5.1.3:快速入门示例中的“损坏”的缩小按钮吗?

时间:2018-08-10 09:37:34

标签: openlayers

我尝试从google地图切换到osm,并尝试使用OpenLayers(快速入门示例)。 如果我使用托管版本,则一切正常。但是,如果我下载5.1.3软件包并将其托管在我们的Web服务器上,则缩小按钮的标题已损坏。网址:http://www.canalcup-cam.de/maps.php
看起来好像使用了非ASCII“-” ... 我试图找到设置按钮标题的代码,但是没有成功。 网站的编码与此有关吗?我尝试了utf-8和Windows-1250。

关于,

2 个答案:

答案 0 :(得分:3)

当我获取代码副本并链接到ol.js副本时,我需要插入<meta charset="utf-8">作为减号(它是html &minus;而不是连字符)才能正确显示:< / p>

  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.1.3/css/ol.css" type="text/css">
    <style>
      .map {
        height: 400px;
        width: 100%;
      }
    </style>
    <script src="http://www.canalcup-cam.de/inc/OpenLayers/v5.1.3/build/ol.js"></script>

    <title>OpenLayers example</title>
  </head>

但是使用ol.js的CDN版本时,无需meta标签即可使用。也许您的副本已经过某种更改,但是始终包含meta标签仍然是一种好习惯。

  <head>
    <link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.1.3/css/ol.css" type="text/css">
    <style>
      .map {
        height: 400px;
        width: 100%;
      }
    </style>
    <script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.1.3/build/ol.js"></script>

    <title>OpenLayers example</title>
  </head>

答案 1 :(得分:1)

字符损坏通常是由错误的编码引起的。有很多可能发生的地方。就您而言,它位于meta标记中。

您似乎喜欢逆流而上,因此在网站上添加了元标记<meta charset="windows-1250">。甚至没有5%的网站不再使用Latin-1 / Windows-1252,世界正在使用UTF-8融合-您也应该切换。