123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- /**
- * Created by Administrator on 2017/12/25.
- */
- function postToIframeMethed(methedName, data, backFun) {
- // if(typeof(exec_obj)=='undefined'){
- // exec_obj = document.createElement('iframe');
- // exec_obj.name = 'tmp_frame';
- // exec_obj.src = 'http://139.196.105.31/HKGisShare/ZoomIn.html';
- // exec_obj.style.display = 'none';
- // document.body.appendChild(exec_obj);
- // }else{
- // exec_obj.src = 'http://139.196.105.31/HKGisShare/ZoomIn.html?' + Math.random();
- // }
- var win = document.getElementsByTagName('iframe')[0].contentWindow;
- // var obj = { name: 'Jack' };
- // 存入对象
- win.postMessage(JSON.stringify({method: methedName, data: data, backfun: backFun}), '*');
- // 读取对象
- // win.postMessage(JSON.stringify({key: 'storage', method: "get"}), "*");
- // window.onmessage = function(e) {
- // if (e.origin != 'http://localhost') return;
- // // "Jack"
- // console.log(JSON.parse(e.data).name);
- // };
- }
- window.onmessage = function (e) {
- //alert(e.origin);
- //if (e.origin !== 'http://10.101.35.46/WJGisShare/')
- //return;
- var payload;
- try {
- payload = JSON.parse(e.data);
- }
- catch (e) {
- return;
- }
- switch (payload.method) {
- case "clickLightAreaReturn":
- {
- clickLightAreaReturn(payload.data[0]);
- break;
- }
- case "clickWaterTankReturn":
- {
- clickWaterTankReturn(payload.data[0]);
- break;
- }
- case "moveInLightAreaReturn":
- {
- moveInLightAreaReturn(payload.data[0]);
- break;
- }
- case "moveOutLightAreaReturn":
- {
- moveOutLightAreaReturn(payload.data[0]);
- break;
- }
- case "moveOutDrawLayerReturn":
- {
- moveOutDrawLayerReturn(payload.data[0]);
- break;
- }
- case "moveInDrawLayerReturn":
- {
- moveInDrawLayerReturn(payload.data[0]);
- break;
- }
- case "clickDrawLayerReturn":
- {
- clickDrawLayerReturn(payload.data[0]);
- break;
- }
- case "clickWZXYFeatureReturn":{
- clickWZXYFeatureReturn(payload.data[0]);
- break;
- }
- case "doXyToStreetIdReturn":
- {
- doXyToStreetIdReturn(payload.data[0])
- break
- }
- case "popupClickReturn":
- {
- doPopupClickReturn(payload.data[0])
- break
- }
- case "closePopupReturn":
- {
- closePopupReturn(payload.data[0]);
- break
- }
- }
- };
- function ZoomIn(level) {
- postToIframeMethed("ZoomIn", level)
- }
- function ZoomOut(level) {
- postToIframeMethed("ZoomOut", level)
- }
- function Clear(type) {
- //var type = "drawLayer" // all drawLayer queryLayer chartLayer
- postToIframeMethed("Clear", type)
- }
- function ViewChange() {
- postToIframeMethed("ViewChange")
- }
- function fullExtent() {
- postToIframeMethed("fullExtent");
- }
- function doSetExtent(num) {
- postToIframeMethed("doSetExtent", num);
- }
- function measureSquare() {
- postToIframeMethed("measureSquare");
- }
- function measureLength() {
- postToIframeMethed("measureLength");
- }
- function downLoadPicture() {
- postToIframeMethed("downLoadPicture");
- }
- function doGetGraphicByJson(jsonStr, isGoTo) {
- postToIframeMethed("doGetGraphicByJson", [jsonStr, isGoTo]);
- }
- function doDeletePointById(id) {
- postToIframeMethed("doDeletePointById", [id]);
- }
- function doShowAreaName(type, fieldName, bool, size, color) {
- postToIframeMethed("doShowAreaName", [type, fieldName, bool, size, color]);
- }
- function drawSquare() {
- postToIframeMethed("drawSquare");
- }
- function query(Str, layerName) {
- postToIframeMethed("query", [Str, layerName]);
- }
- function queryByWhereStr(Str, layerName) {
- postToIframeMethed("queryByWhereStr", [Str, layerName]);
- }
- function doOpenFeatureLayer(layerId, layerVisible) {
- postToIframeMethed("openFeatureLayer", [layerId, layerVisible])
- }
- function doOpenFeatureLayerByName(layerName, layerVisible, whereStr) {
- postToIframeMethed("openFeatureLayerByName", [layerName, layerVisible, whereStr])
- }
- function doCloseChangeLayer() {
- postToIframeMethed("CloseChangeLayer", [])
- }
- function doOpenFeatureLayer0(layerVisible) {
- postToIframeMethed("openFeatureLayer0", [layerVisible])
- }
- function doOpenFeatureLayer1(layerVisible) {
- postToIframeMethed("openFeatureLayer1", [layerVisible])
- }
- function doOpenFeatureLayer2(layerVisible) {
- postToIframeMethed("openFeatureLayer2", [layerVisible])
- }
- function doOpenFeatureLayer3(layerVisible) {
- postToIframeMethed("openFeatureLayer3", [layerVisible])
- }
- function doOpenFeatureLayer4(layerVisible) {
- postToIframeMethed("openFeatureLayer4", [layerVisible])
- }
- function doOpenFeatureLayer5(layerVisible) {
- postToIframeMethed("openFeatureLayer5", [layerVisible])
- }
- function doOpenFeatureLayer6(layerVisible) {
- postToIframeMethed("openFeatureLayer6", [layerVisible])
- }
- function doOpenFeatureLayer7(layerVisible) {
- postToIframeMethed("openFeatureLayer7", [layerVisible])
- }
- function doOpenFeatureLayer8(layerVisible) {
- postToIframeMethed("openFeatureLayer8", [layerVisible])
- }
- function doOpenFeatureLayer9(layerVisible) {
- postToIframeMethed("openFeatureLayer9", [layerVisible])
- }
- function doOpenFeatureLayer10(layerVisible) {
- postToIframeMethed("openFeatureLayer10", [layerVisible])
- }
- function doFlashStatus(layerName) {
- postToIframeMethed("doFlashStatus", [layerName])
- }
- function setCenterExtentByPointR(x, y, radius) {
- postToIframeMethed("setCenterExtent", [x, y, radius])
- }
- function doDrawCircle(color) {
- postToIframeMethed("drawCircle", [color]);
- }
- function doQueryByCircle(layerName, picUrl, width, height) {
- postToIframeMethed("queryByCircle", [layerName, picUrl, width, height])
- }
- // 2019 12 by hm
- function doOnLocation(x, y, Attribute, ToolTip, ImgUrl, ImgWidth, ImgHeight) {
- postToIframeMethed("onLocation", [x, y, Attribute, ToolTip, ImgUrl, ImgWidth, ImgHeight]);
- }
- function doMeasureLengthByPoint(x, y, x1, y1, backFun) {
- postToIframeMethed("MeasureLengthByPoint", [x, y, x1, y1], backFun);
- }
- function doNewQuery(str, layerName, isgoto) {
- postToIframeMethed("newQuery", [str, layerName, isgoto]);
- }
- function doGridQuery(str, isgoto) {
- doNewQuery(str, "责任网格", isgoto);
- }
- function doOnLocationforGrid(x, y) {
- postToIframeMethed("onLocationforGrid", [x, y]);
- }
- function doOnLocationforAddress(x, y) {
- postToIframeMethed("onLocationforAddress", [x, y]);
- }
- function doOnQueryByPoint(x, y, layername, radius, isshow, isGoTo) {
- postToIframeMethed("onQueryByPoint", [x, y, layername, radius, isshow, isGoTo]);
- }
- function doOnQueryByGrid(grid, layername) {
- postToIframeMethed("onQueryByGrid", [grid, layername]);
- }
- function doOnMapCenter() {
- postToIframeMethed("onMapCenter");
- }
- function doOnMapLevel() {
- postToIframeMethed("onMapLevel");
- }
- function doOnMapSetCenter(x, y) {
- postToIframeMethed("onMapSetCenter", [x, y]);
- }
- function doOnGetXYbyAddress(str) {
- postToIframeMethed("onGetXYbyAddress", [str]);
- }
- function doOnSetInitExtentByStr(layername, streetname) {
- postToIframeMethed("onSetInitExtentByStr", [layername, streetname]);
- }
- function doOnQueryByCondition(str, layername, isShow, isGoTo) {
- postToIframeMethed("onQueryByCondition", [str, layername, isShow, isGoTo]);
- }
- function doOpenFeatureLayerByNameandWhere(layername, type, name, isGoTo, isOpen) {
- postToIframeMethed("openFeatureLayerByNameandWhere", [layername, type, name, isGoTo, isOpen]);
- }
- //2020 2 by hm
- function doOnClickLocation(Attribute, ToolTip, ImgUrl, ImgWidth, ImgHeight) {
- postToIframeMethed("onClickLocation", [Attribute, ToolTip, ImgUrl, ImgWidth, ImgHeight]);
- }
- //2020 4 by hm
- function doOnSetResizeType(type, radius, layername) {
- postToIframeMethed("onSetResizeType", [type, radius, layername]);
- }
- function doOnSetLayerCluster(layername, iscluster) {
- postToIframeMethed("onSetLayerCluster", [layername, iscluster]);
- }
- function doOnShowPolygonandText(jsonarr) {
- postToIframeMethed("onShowPolygonandText", [jsonarr]);
- }
- //2020 9 by hm
- function doOnLocationGetLatLon(color) {
- postToIframeMethed("onLocationGetLatLon", [color]);
- }
- function doOnDrawPolygonCircle() {
- postToIframeMethed("onDrawPolygonCircle");
- }
- function doOnDrawPolygonSquare() {
- postToIframeMethed("onDrawPolygonSquare");
- }
- function doOnLightArea(type, where, color, orderField) {
- postToIframeMethed("onLightArea", [type, where, color, orderField]);
- }
- function doEchartsRoute(dataArray, color, imgSrc, imgsize) {
- postToIframeMethed("onEchartsRoute", [dataArray, color, imgSrc, imgsize]);
- }
- function doWaterRouteClick(whereStr) {
- postToIframeMethed("doWaterRouteClick", [whereStr]);
- }
- function doPopupIn(popupInfoArray, hasX) {
- postToIframeMethed("onPopupIn", [popupInfoArray, hasX]);
- }
- function doClosePopupIn() {
- postToIframeMethed("onPopupClose");
- }
- function doCorrugatedPointByOid(list) {
- postToIframeMethed("doCorrugatedPointByOid", [list]);
- }
- function doClearCorrugatedPoint() {
- postToIframeMethed("doClearCorrugatedPoint", []);
- }
- function doXyToStreetId(x, y) {
- postToIframeMethed("doXyToStreetId", [x, y]);
- }
- function doGoToGraphic(type,graphic) {
- postToIframeMethed("goToGraphic", [type, graphic]);
- }
- function doGoToJZ(type,graphic,radius){
- postToIframeMethed("GoToJZ", [type, graphic,radius]);
- }
- function ShowBuildlayer(where){
- postToIframeMethed("ShowBuildlayer", [where]);
- }
- function switch2Dor3DMap(where) {
- postToIframeMethed("switch2Dor3DMap", [where]);
- }
- function ShowBuildlayerSX(where){
- postToIframeMethed("ShowBuildlayerSX", [where]);
- }
- function ResettingMap(){
- postToIframeMethed("ResettingMap", []);
- }
- function consoleXYZ(){
- postToIframeMethed("consoleXYZ", []);
- }
- function doClusterByJson(jsonArray) {
- postToIframeMethed("doClusterByJson", [jsonArray]);
- }
- ////////////////////////////////////////////////////////////////////////
- window.addEventListener('message', function (e) {
- var data;
- try {
- data = JSON.parse(e.data);
- }catch(err){
- data=e.data
- }
- switch (data.method) {
- case "measureLengthCallback":
- {
- measureLengthCallback(data.data[0]);
- break;
- }
- case "identifyTaskcallbackfun":
- {
- identifyTaskcallbackfun(data.data[0]);
- break;
- }
- case "maploadCallback":
- {
- maploadCallback();
- break;
- }
- case "addressdataCallback":
- {
- addressdataCallback(data.data[0]);
- break;
- }
- case "dragendCallback":
- {
- dragendCallback();
- break;
- }
- case "queryByGeometryAndLayer":
- {
- queryByGeometryAndLayer(data.data[0]);
- break;
- }
- case "mapCenterCallback":
- {
- mapCenterCallback(data.data[0]);
- break;
- }
- case "mapOnclickCallback":
- {
- mapOnclickCallback(data.data[0], data.data[1]);
- break;
- }
- case "mapLevelCallback":
- {
- mapLevelCallback(data.data[0]);
- break;
- }
- case "resizeCallback":
- {
- resizeCallback();
- break;
- }
- case "XYbyAddressCallback":
- {
- XYbyAddressCallback(data.data[0]);
- break;
- }
- case "mapAnimationInProgressCallback":
- {
- mapAnimationInProgressCallback();
- break;
- }
- case "mapDragingCallback":
- {
- mapDragingCallback();
- break;
- }
- case "clicklocationcallbackfun":
- {
- clicklocationcallback(data.data[0], data.data[1]);
- break;
- }
- case "onLocationGetLatLonbackfun":
- {
- onLocationGetLatLonbackfun(data.data[0]);
- break;
- }
- case "onDrawPolygoncallbackfun":
- {
- onDrawPolygoncallbackfun(data.data[0]);
- break;
- }
- }
- }, false);
- function measureLengthCallback(len) {
- console.log(len);
- }
- function identifyTaskcallbackfun(results) {
- console.log("网格编码=" + results);
- }
- function maploadCallback() {
- console.log("maploaded");
- }
- function addressdataCallback(address) {
- console.log(address);
- }
- function dragendCallback() {
- console.log("dragend");
- }
- function queryByGeometryAndLayer(data) {
- console.log(data);
- }
- function mapCenterCallback(data) {
- // alert(data);
- }
- function mapOnclickCallback(data, gridid) {
- alert(data + "网格编码=" + gridid);
- }
- function mapLevelCallback(data) {
- // alert(data);
- }
- function resizeCallback() {
- console.log("mapresize");
- }
- function XYbyAddressCallback(data) {
- // alert(data);
- console.log(data);
- }
- function mapAnimationInProgressCallback() {
- console.log("mapAnimationInProgressCallback");
- }
- function mapDragingCallback() {
- console.log("mapDragingCallback");
- }
- function clicklocationcallback(data, lonlat) {
- console.log(data);
- console.log(lonlat);
- }
- function onLocationGetLatLonbackfun(data) {
- console.log(data);
- }
- function onDrawPolygoncallbackfun(data) {
- console.log(data);
- }
|