首页 / 浏览问题 / 云GIS / 问题详情
添加GeoText报错
6EXP 2018年05月31日
var geoText = new SuperMap.Geometry.GeoText(100, 35,"中华人民共和国"); 
var geotextFeature = new SuperMap.Feature.Vector(geoText); 
 
//新建一个策略并使用在矢量要素图层(vector)上。 
var strategy = new SuperMap.Strategy.GeoText(); 
strategy.style = { 
  fontColor:"#FF7F00", 
  fontWeight:"bolder", 
  fontSize:"14px", 
  fill: true, 
  fillColor: "#FFFFFF", 
  fillOpacity: 1, 
  stroke: true, 
  strokeColor:"#8B7B8B" 
}; 
var vectorLayer = new SuperMap.Layer.Vector("Label",{strategies: [strategy]}); 
map.addLayers([vectorLayer]); 
 
vectorLayer.addFeatures([geotextFeature]);

用上述代码添加地图文本要素,报错!

1个回答

您好,接口没问题,请检查你的代码

<script type="text/javascript">
	var map, layer, pointVector, 
	url = "http://localhost:8090/iserver/services/map-world/rest/maps/World";
	function init() {
		map = new SuperMap.Map("map");
		layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null, { maxResolution: "auto" });
		layer.events.on({ "layerInitialized": addLayer });
		vector = new SuperMap.Layer.Vector("vector");
		addData();
	}
	function addLayer() {
		map.addLayers([layer, vector]);
		map.setCenter(new SuperMap.LonLat(0, 0), 0);
	}
	function addData() {
		var geoText = new SuperMap.Geometry.GeoText(100, 35, "中华人民共和国");
		var geotextFeature = new SuperMap.Feature.Vector(geoText);
		var strategy = new SuperMap.Strategy.GeoText();
		strategy.style = {
			fontColor: "#FF7F00",
			fontWeight: "bolder",
			fontSize: "14px",
			fill: true,
			fillColor: "#FFFFFF",
			fillOpacity: 1,
			stroke: true,
			strokeColor: "#8B7B8B"
		};
		var vectorLayer = new SuperMap.Layer.Vector("Label", { strategies: [strategy] });
		map.addLayers([vectorLayer]);
		vectorLayer.addFeatures([geotextFeature]);
	}
</script>

4,524EXP 2018年06月01日
...