var zNodes =[
{ id:"base", pId:0, name:"行政区划图", open:true},
{ id:"china:capital", pId:"base", name:"省会城市"},
{ id:"china:pro_polygon", pId:"base", name:"省级行政区"},
{ id:"theme", pId:0, name:"专题图", open:true},
{ id:"china:lake", pId:"theme", name:"湖泊"}
]
1.引入OL3的js文件和css文件<link rel="stylesheet" href="http://openlayers.org/en/v3.16.0/css/ol.css" type="text/css">
<script src="http://openlayers.org/en/v3.16.0/build/ol.js"></script>
<div id="map" class="map" tabindex="0"></div>
3.首先加载地图,然后加载geojson文件
var vectorone = new ol.layer.Tile({
source: new ol.source.OSM()
})
//加载geojson数据
var GeoJsonLayer = new ol.layer.Vector({
title: 'add Layer',
source: new ol.source.Vector({
projection: 'EPSG:4326',
url: './geojson/countries.geojson',
format:new ol.format.GeoJSON()
})
})
4. //加载地图
var map = new ol.Map({
layers: [
vectorone, GeoJsonLayer
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: true
})
}),
view: new ol.View({
center: [52.5243700, 13.4105300],
zoom: 2
})
})
5.会出现不能读geojson的情况
1.在iis中配置geojson的数据格式,Mime类型
2.或者在web.config文件下添加
<system.webServer>
<staticContent>
<mimeMap fileExtension=".geojson" mimeType="application/geojson"/>
</staticContent>
</system.webServer>
目的:使用ArcGIS Server(ADF)实现两个地图服务叠加的应用。1.建立地图服务
首先建立两个Map Service:USA 和 NorthAmerica。进行设定两个地图的绘制方式:
USA: Dynamically from the data
NorthAmerica: Using tiles from its cache
2.添加地图服务
在MapResourceManager控件中添加上面的两个地图服务。
NorthAmerica 为items0, USA为items1.
在MapResoureItem集合编辑器中设置,DisplaySettings参数。在 Make backgroud transparent 复选框前面打钩即可。
3.使用地图服务
设置Map控件的MapResourceManager属性为上一步中的MapResourceManager控件。
然后把Map控件的 PrimaryMapResource 属性设置为NorthAmerica 地图服务。
具体 HTML 代码及效果图如下:
[xhtml] view plain copy
<esri:MapResourceManager ID="MapResourceManager1" runat="server" style="position: absoluteleft: 344pxtop: 130pxz-index: 503" OnResourceInit="MapResourceManager1_ResourceInit">
<ResourceItems>
<esri:MapResourceItem Definition="<Definition DataSourceDefinition="wl" DataSourceType="ArcGIS Server Local" Identity="To set, right-click project and 'Add ArcGIS Identity'" ResourceDefinition="Layers@USA" DataSourceShared="True" />"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=96:color=White:transbg=True:displayInToc=True:dynamicTiling="
LayerDefinitions="" Name="美国" />
<esri:MapResourceItem Definition="<Definition DataSourceDefinition="wl" DataSourceType="ArcGIS Server Local" Identity="To set, right-click project and 'Add ArcGIS Identity'" ResourceDefinition="Layers@NorthAmerica" DataSourceShared="True" />"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=96:color=:transbg=False:displayInToc=True:dynamicTiling="
LayerDefinitions="" Name="北美" />
</ResourceItems>
</esri:MapResourceManager>
<esri:Map ID="Map1" runat="server" MapResourceManager="MapResourceManager1"
Height="100%" Width="100%" PrimaryMapResource="北美" >
</esri:Map>
需要注意的:
PrimaryMapResource 的控件参考决定了整个地图的控件参考。
Make backgroud transparent 决定了当前地图服务的图片是否为透明,此属性为False时,将遮盖其下层地图服务。
上例中的 USA 地图服务的绘制类型也可以是 Using tiles from its cache 效果会稍有不同,但不会影响地图服务的叠加整体效果。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)