2016-04-26 12 views
1

Ich muss Graticule Etiketten in OpenLayers 3 laufen lassen. Ich möchte Etiketten mit Rastereinheiten zeigen und stylen. Ich habe gerade dies:Wie werden Rastermarken in OpenLayers 3 ausgeführt?

https://github.com/Brictarus/ol3/blob/d41eb87204e76cbf99d61915eb89b1c16c4a4e05/examples/graticule.js

Aber ich kann nicht bekommen es in meinem html funktioniert:

var polohaMysky = new ol.control.MousePosition({ 
    coordinateFormat: ol.coordinate.createStringXY(4), 
    //projection: "EPSG:4326", 
    className: "suradnice", 
    target: document.getElementById("suradnice_div"), 
       undefinedHTML: '0000' 
}) 
      //------// 
      var mierka = new ol.control.ScaleLine(); 
      var nahlad = new ol.control.OverviewMap(); 
      var a1 = new ol.source.OSM(); 
     var map = new ol.Map({ 
     renderer: 'canvas', 
      // Zobrazenie súradníc myšky 
     controls: ol.control.defaults({ 
      attributions: false 
     }).extend([polohaMysky, mierka, nahlad]), 
     layers: [ 
      new ol.layer.Tile({ 
      source: a1 
      }) 
     ], 
     target: 'map', 
     view: new ol.View({ 
      //projection: 'EPSG:4326', 
      center: ol.proj.fromLonLat([4.8, 47.75]), 
      zoom: 3 
     }) 
     }); 
      var lonFormatter = function(lon) { 
    var formattedLon = Math.abs(Math.round(lon * 100)/100); 
    formattedLon += (lon < 0) ? 'W' : ((lon > 0) ? 'E' : ''); 
    return formattedLon; 
}; 

var latFormatter = function(lat) { 
    var formattedLat = Math.abs(Math.round(lat * 100)/100); 
    formattedLat += (lat < 0) ? 'S' : ((lat > 0) ? 'N' : ''); 
    return formattedLat; 
}; 

// Create the graticule component 
var graticule = new ol.Graticule({ 
    // the style to use for the lines, optional. 
    strokeStyle: new ol.style.Stroke({ 
    color: 'rgba(255,120,0,0.9)', 
    width: 2, 
    lineDash: [0.5, 4] 
    }), 
    showLabels: true, 
    lonLabelFormatter: lonFormatter, 
    lonLabelPosition: 0.05, 
    latLabelFormatter: latFormatter, 
    latLabelPosition: 0.95 
}); 
graticule.setMap(map); 

Wenn ich diesen Code ausführen ich sehe gerade nur graticule ohne Etiketten. Hast du eine Ahnung was falsch ist? Danke für jede Hilfe.

+0

Dieser Antrag ziehen wird OL nicht verschmolzen. Es wird also nicht funktionieren, ohne ol.js zu verändern. Sehen Sie sich das vollständige Änderungsprotokoll an und versuchen Sie, alle Änderungen an ol.js zusammenzuführen, und es könnte funktionieren. https://github.com/Brictarus/ol3/commit/d41eb87204e76cbf99d61915eb89b1c16c4a4e05 – itsyahani

+0

Ich füge hinzu/lade das geändert olx.js und graticule.js von diesem Link auf dem Kopf, aber es funktioniert nicht, Etiketten nirgends. –

Antwort

Verwandte Themen