123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /**
- * @fileoverview 城市地质
- * @author Lei.Xu
- * @version 1.0.0
- */
- define([], function(tplLayout, addressSearchF, poiSearchF, regionSearchF, routeSearchF) {
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- markerGroup: null, //marker容器
- markers: [], //marker记录
- citys: [[119.18,26.03],[118.34,24.55],[112.11,32.05],[126.37,45.44]],
- };
- /**
- * 模块状态,用于存储模块的状态 例如:收起,关闭
- * @type {Object}
- */
- var status = {
- initialized: false //是否初始化
- };
- /**
- * 初始化并订阅事件
- * @return {[type]} [description]
- */
- function init() {
- if (!status.initialized) {
- subscribe();
- status.initialized = true;
- modValue.markerGroup = map23DControl.group({
- action: 'add'
- });
- for(var i=0;i<modValue.citys.length;i++){
- addCitys(modValue.citys[i]);
- }
- //添加到我的图层
- var cityGuid = map23DControl.buildGuid('cityGeology');
- var layerOptions = {
- action: "add",
- DOM: {
- guid: cityGuid,
- type: '',
- name: '城市地质'
- },
- mod: ''
- }
- ONEMAP.M.myLayers.myLayerControl(layerOptions);
- ONEMAP.C.publisher.subscribe(layerAction, layerOptions.DOM.guid);
- $("#cityGeology").attr("layer",cityGuid);
- map2DViewer.map.setView([39,116],5);
- } else{
- removeAll();
- status.initialized = false;
- }
- };
- function addCitys(cityCoors){
- var markerId = map23DControl.marker({
- action: 'add',
- groupId: modValue.markerGroup,
- geojson: {
- "properties": {
- iconUrl: map23DConfig.map23DAssetsUrl + '/images/layout/marker/roadsign_icon_0.png',
- iconSize: [60, 39],
- iconAnchor: [29, 39],
- popupAnchor: [0, -39]
- },
- "geometry": {
- "type": "Point",
- "coordinates": [cityCoors[0],cityCoors[1]]
- }
- }
- });
- modValue.markers.push(markerId);
- map2DViewer.markers[markerId].on('click', function() {
- var iframeDom = $('<div class="main"><iframe src="'+onemapUrlConfig.geolink+'" id="myiframe" scrolling="yes" frameborder="0"></iframe><div class="bk">返回</div></div>');
- $("body").append(iframeDom)
- iframeDom.ready(function(){
- var at = setInterval(function(){
- var deptObjs= document.getElementById("myiframe").contentWindow.document.getElementById("north");
- var deptops= document.getElementById("myiframe").contentWindow.document.querySelectorAll(".layout-panel");
- deptObjs.style.display = "none";
- for(var i=0;i<deptops.length;i++){
- deptops[i].style.top = "0"
- }
- // console.log(deptObjs.style.display);
- // console.log(deptops.length);
- if(deptObjs.style.display=="none"){
- clearInterval(at);
- }
- },50)
- })
- $(".bk").bind("click",function(){
- $(".main").remove();
- })
- });
- }
- function getDom(){
- console.log("out getdom");
- }
- // 设置透明度
- function setOpacity(zid, opt) {
- map23DControl.tileLayer({
- action: 'update',
- guid: zid,
- layer: {
- opacity: opt
- }
- })
- }
- // 监听图层操作动作
- function layerAction(options) {
- if (options.action == "remove") {
- removeAll(options.guid);
- } else if (options.action == "opacity") {
- var opt = options.options.opacity;
- setOpacity(options.guid, opt);
- }
- }
- function removeAll(){
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.markerGroup
- })
- $("#cityGeology").removeClass('current');
- status.initialized = false;
- // map23DControl.marker({
- // action: 'remove',
- // guid: guid
- // })
- }
- /**
- * 注册监听
- * @type {Function}
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(removeAll, 'cleanMap');
- };
- return ONEMAP.M.cityGeology = {
- init: init,
- removeAll: removeAll
- }
- })
|