首页 / 浏览问题 / 云GIS / 问题详情
marker里面添加数字
34EXP 2019年11月26日
基于iClient Classic,想要在marker里面添加一个数字,用什么对象

1个回答

SuperMap.Marker 在classic api中只提供了可以设置imgicon的参数。不能为其设置style。如果你那边想为点设置数字,建议使用

SuperMap.Feature.Vector对象可以设置style 
var geometry = new SuperMap.Geometry.Point(105, 35);
var pointFeature = new SuperMap.Feature.Vector(geometry);
var styleTest = {
      label:"supermap",
      fontColor:"#0000ff",
      fontOpacity:"0.5",
      fontFamily:"隶书",
      fontSize:"8em",
      fontWeight:"bold",
      fontStyle:"italic",
      labelSelect:"true",
   }
         pointFeature.style = styleTest;
        vectorLayer.addFeatures([pointFeature]);
3,352EXP 2019年11月26日
size = new SuperMap.Size(35, 35);
offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
icon = new SuperMap.Icon("img/marker-red.png", size, offset);
geoText=new SuperMap.Geometry.GeoText(point.x,point.y,count++);
geotextFeature=new SuperMap.Feature.Vector(geoText);
strategy=new SuperMap.Strategy.GeoText();
strategy.style={
    //fontColor:"#FFFFFF",
    fontSize:"14px",
    labelYOffset:12
}
vectorLayer=new SuperMap.Layer.Vector("Label",{strategies:[strategy]});
map.addLayers([markerLayer,vectorLayer]);

现在这样设置了,我先设置了一个图标,然后再图标上添加一个数字,但是数字一直再图标下面,怎么可以把数字放在上面呢

你那边如果是想做到图标和数字不重合,可以选择,稍微偏移你的geotext对象
...