javascript - openlayers feature label not showing -


i'm using custom icon (png) features can't label display. can see i've added in everywhere trying work? please can spot i'm going wrong?

many thanks

var iconfeature = new ol.feature({     geometry: new ol.geom.point(ol.proj.transform([0.0488567 - 0.003, -0.02275 + 0.00115 ], 'epsg:4326', 'epsg:3857')),     label:"adsfasdf",     name: 'null island',     population: 4000,     rainfall: 500,  }); iconfeature.attributes = {label: "sadfd"} //new openlayers.lonlat(51.5, -0.117) var iconstyle = new ol.style.style({     image: new ol.style.icon(/** @type {olx.style.iconoptions} */ ({         anchor: [0.5, 46],         anchorxunits: 'fraction',         anchoryunits: 'pixels',         opacity: 0.75,         src: 'assets/pins/pin-blue.png',         label: "kasds"     })) }); iconfeature.setstyle(iconstyle);  var iconfeature2 = new ol.feature({     geometry: new ol.geom.point([5389, -1282]),     name: 'null island2',     population: 4000,     rainfall: 500, }); var iconstyle2 = new ol.style.style({     image: new ol.style.icon(/** @type {olx.style.iconoptions} */ ({         anchor: [0.5, 46],         anchorxunits: 'fraction',         anchoryunits: 'pixels',         opacity: 0.75,         src: 'assets/pins/pin-blue.png',         label: "kasds",         fontsize: "12px",         fontfamily: "courier new, monospace"     })) }); iconfeature2.setstyle(iconstyle2);  var vectorsource = new ol.source.vector({     features: [iconfeature,iconfeature2] });  var vectorlayer = new ol.layer.vector({     source: vectorsource });   var imgwidth = 12241;// 32241; var imgheight = 5768;//15191; var url = 'assets/map/'; var crossorigin = 'anonymous'; var imgcenter = [imgwidth / 2, - imgheight / 2]; var proj = new ol.proj.projection({     code: 'zoomify',     units: 'pixels',     extent: [0, 0, imgwidth, imgheight] });  var source = new ol.source.zoomify({     url: url,     size: [imgwidth, imgheight],     crossorigin: crossorigin });  var map = new ol.map({     layers: [         new ol.layer.tile({             source: source         }),         vectorlayer     ],     renderer: common.getrendererfromquerystring(),     target: 'map',     view: new ol.view({         projection: proj,         center: imgcenter,         zoom: 3,         minzoom: 3,         maxzoom: 5,         extent: [0, -imgheight, imgwidth, 0]     }) }); 

the text style has passed parameter text ol.style.style:

var iconstyle = new ol.style.style({   image: new ol.style.icon({     ...   })),   text: new ol.style.text({       text: 'the label',       fill: new ol.style.fill({color: 'black'}),       stroke: new ol.style.stroke({color: 'yellow', width: 1}),       offsetx: -20,       offsety: 20   }) }); 

http://jsfiddle.net/54a8pktt/

see example: http://openlayers.org/en/master/examples/vector-labels.html


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -