0

我有利比亚地图,但我不想以原始阿拉伯字母显示,而是以意大利语或英文字符显示,我该怎么做?如果我可以只用一种语言显示所有地图,那就更好了……

这是我的代码

<body  onload="init()">
<div id="map" id="map"></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>

var map;
function init() {

// The overlay layer for our marker, with a simple diamond as symbol
var overlay = new OpenLayers.Layer.Vector('Overlay', {
    styleMap: new OpenLayers.StyleMap({
        externalGraphic: 'ico_soggiorno.png',
        graphicWidth: 20, graphicHeight: 20, graphicYOffset: -20,
        title: 'test'
    })
});

// The location of our marker and popup. We usually think in geographic
// coordinates ('EPSG:4326'), but the map is projected ('EPSG:3857').
var myLocation = new OpenLayers.Geometry.Point( 13.1833326, 32.6833306 )
    .transform('EPSG:4326', 'EPSG:3857');

// We add the marker with a tooltip text to the overlay
overlay.addFeatures([
    new OpenLayers.Feature.Vector(myLocation, {tooltip: 'OpenLayers'})
]);

// Finally we create the map
map = new OpenLayers.Map({
    div: "map", projection: "EPSG:3857",
    layers: [new OpenLayers.Layer.OSM(), overlay],
    center: myLocation.getBounds().getCenterLonLat(), zoom: 7
});

}

4

1 回答 1

0

使用 osmappa.it 磁贴,它看起来像这样:

<body  onload="init()">
<div id="map" id="map"></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>

var map;
function init() {

var osmappa = new TileLayer({
  source: new OSM({
    attributions: [
      'Tiles © <a href="https://www.osmappa.it/">osMap</a>',
      ATTRIBUTION
    ],
    url: 'https://osmap.{a-d}.tile.maphost.it/it/map/v1/{z}/{x}/{y}.png'
    //ask them first if you can use those tiles!
  })
});

// The overlay layer for our marker, with a simple diamond as symbol
var overlay = new OpenLayers.Layer.Vector('Overlay', {
    styleMap: new OpenLayers.StyleMap({
        externalGraphic: 'ico_soggiorno.png',
        graphicWidth: 20, graphicHeight: 20, graphicYOffset: -20,
        title: 'test'
    })
});

// The location of our marker and popup. We usually think in geographic
// coordinates ('EPSG:4326'), but the map is projected ('EPSG:3857').
var myLocation = new OpenLayers.Geometry.Point( 13.1833326, 32.6833306 )
    .transform('EPSG:4326', 'EPSG:3857');

// We add the marker with a tooltip text to the overlay
overlay.addFeatures([
    new OpenLayers.Feature.Vector(myLocation, {tooltip: 'OpenLayers'})
]);

// Finally we create the map
map = new OpenLayers.Map({
    div: "map", projection: "EPSG:3857",
    layers: [osmappa, overlay],
    center: myLocation.getBounds().getCenterLonLat(), zoom: 7
});

这将是您使用意大利瓷砖的代码的变体。但请先问他们,也许您需要一个 apikey 或类似的东西,因为现在看起来这些图块似乎只为 osmappa.it 而不是为其他项目加载。

于 2020-04-14T13:12:20.263 回答