简体   繁体   English

Openlayers 2 显示粉色 map (layer) by Iphone

[英]Openlayers 2 show pink map (layer) by Iphone

My goal is to track my current position by smartphone and show this on the map.我的目标是通过智能手机跟踪我当前的 position 并将其显示在 map 上。 For this I'm using openlayers 2.为此,我使用的是 openlayers 2。

But now I have the following problem.但现在我有以下问题。 When I use the below code in a Chrome Browser ( Desktop, Android ) it works fine.当我在 Chrome 浏览器(桌面,Android )中使用以下代码时,它工作正常。 If I open the same page in a iPhone ( Safari, Chrome ) I got always instead of the map just a pink layer with the position marker.如果我在 iPhone ( Safari, Chrome ) 中打开相同的页面,我总是得到一个带有 position 标记的粉红色层而不是 map。

  <div id="mapdiv"></div>
  <script src="OpenLayers.js"></script>
  
  <script>
  
    map = new OpenLayers.Map("mapdiv");

    map.addLayer(new OpenLayers.Layer.OSM());

    var lonLat = new OpenLayers.LonLat( -0.1279688 ,51.5077286 )
              .transform(
                new OpenLayers.Projection("EPSG:4326"), // Transformation aus dem Koordinatensystem WGS 1984
                map.getProjectionObject() // in das Koordinatensystem 'Spherical Mercator Projection'
              );

    var zoom=16;

    var markers = new OpenLayers.Layer.Markers( "Markers" );
    map.addLayer(markers);
    
    markers.addMarker(new OpenLayers.Marker(lonLat));
    
    map.setCenter (lonLat, zoom);
    
  </script> 

Can someone help me here?有人可以在这里帮助我吗?

It might be due to mixed content, OpenLayers 2 defaults to http for the OSM url, try specifying https这可能是由于混合内容,OpenLayers 2 默认为 http 对于 OSM url,尝试指定 https

map.addLayer(new OpenLayers.Layer.OSM(
            "OpenStreetMap", [
                "https://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
                "https://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
                "https://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
            ]
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM