leadorStreetViewAPI.js 16 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. function serialization(a) { var b = "{"; for (var c in a) b += '"' + c + '":"' + a[c] + '",'; return b = b.substr(0, b.length - 1), b += "}" }
  2. function FlashInitError(a) { LeadorStreetView.errorEvent && LeadorStreetView.errorEvent(a) }
  3. function ServerLoadError(a) { LeadorStreetView.errorEvent && LeadorStreetView.errorEvent(a) }
  4. function PreviewLoadError(a) { LeadorStreetView.errorEvent && LeadorStreetView.errorEvent(a) }
  5. function FlashMapInitEnd() { LeadorStreetView.initStreetView = !1, LeadorStreetView.appObject && (null != LeadorStreetView.addMarkerButtonView && LeadorStreetView.showMarkerUI(LeadorStreetView.addMarkerButtonView), null != LeadorStreetView.closeButtonView && LeadorStreetView.showCloseUI(LeadorStreetView.closeButtonView), null != LeadorStreetView.fullButtonView && LeadorStreetView.showFullScreenUI(LeadorStreetView.fullButtonView), null != LeadorStreetView.guideView && LeadorStreetView.showGuideUI(LeadorStreetView.guideView), null != LeadorStreetView.errorReportView && LeadorStreetView.showErrorReportUI(LeadorStreetView.errorReportView), null != LeadorStreetView.autorunView && LeadorStreetView.showAutorunUI(LeadorStreetView.autorunView), null != LeadorStreetView.compassView && LeadorStreetView.showCompassUI(LeadorStreetView.compassView), null != LeadorStreetView.zoomView && LeadorStreetView.showzoomUI(LeadorStreetView.zoomView), LeadorStreetView.presetAngle && (LeadorStreetView.setStreetViewAngle(LeadorStreetView.presetAngle, !0), LeadorStreetView.presetAngle = null), LeadorStreetView.stationID && "" != LeadorStreetView.stationID ? LeadorStreetView.getBindObject().SetTrueVisonFromID(LeadorStreetView.stationID) : LeadorStreetView.coordinate && LeadorStreetView.coordinate.length > 0 && LeadorStreetView.getBindObject().SetTrueVisonFromCoordinate(LeadorStreetView.coordinate[0], LeadorStreetView.coordinate[1]), null != LeadorStreetView.visibleUI && (1 == LeadorStreetView.visibleUI ? LeadorStreetView.showUI(!0) : 0 == LeadorStreetView.visibleUI && LeadorStreetView.showUI(!1)), LeadorStreetView.streetViewInitEndEvent && LeadorStreetView.streetViewInitEndEvent(), LeadorStreetView.useHash && "onhashchange" in window && (void 0 === document.documentMode || document.documentMode > 7) ? window.addEventListener ? window.addEventListener("hashchange", LeadorStreetView.onhashchangeEvent, !1) : window.attachEvent("onhashchange", LeadorStreetView.onhashchangeEvent) : LeadorStreetView.useHash = !1) }
  6. function TVImageLoadEnd(a) { var b = LeadorStreetView.getStreetViewAngle(); if (LeadorStreetView.stationID = a.StationID, LeadorStreetView.yaw = Math.round(b.yaw), LeadorStreetView.pitch = Math.round(b.pitch), LeadorStreetView.hidePoiBubble(), LeadorStreetView.streetViewCompleteEvent && LeadorStreetView.streetViewCompleteEvent(LeadorStreetView.getStreetViewInfo()), LeadorStreetView.useHash) { var c = LeadorStreetView.getHashVar("stationID");
  7. c != a.StationID && (LeadorStreetView.isHashUpdata = !0, location.hash = "stationID=" + a.StationID + "&yaw=" + LeadorStreetView.yaw + "&pitch=" + LeadorStreetView.pitch) } }
  8. function GetImageNorthAngle(a) { if (LeadorStreetView.yaw = a.yaw, LeadorStreetView.pitch = a.pitch, LeadorStreetView.hidePoiBubble(), LeadorStreetView.angleChangeEvent && LeadorStreetView.angleChangeEvent(a), LeadorStreetView.useHash) { var b = LeadorStreetView.getHashVar("yaw"),
  9. c = LeadorStreetView.getHashVar("pitch");
  10. (Math.abs(LeadorStreetView.yaw - b) > 5 || Math.abs(LeadorStreetView.pitch - c) > 5) && (LeadorStreetView.isHashUpdata = !0, location.hash = "stationID=" + LeadorStreetView.stationID + "&yaw=" + LeadorStreetView.yaw + "&pitch=" + LeadorStreetView.pitch) } }
  11. function ChangeZoomEvent(a) { LeadorStreetView.hidePoiBubble(), LeadorStreetView.zoomChangeEvent && LeadorStreetView.zoomChangeEvent(a) }
  12. function FullSrceenClickEvent() { LeadorStreetView.fullSrceenEvent && LeadorStreetView.fullSrceenEvent() }
  13. function BackMapEvent() { LeadorStreetView.streetViewCloseEvent && LeadorStreetView.streetViewCloseEvent() }
  14. function AddLabelClickEvent() { LeadorStreetView.plusMarkerEvent && LeadorStreetView.plusMarkerEvent() }
  15. function CoordinatesEvent(a) { if (LeadorStreetView.coordinatesEvent) { var b = LeadorStreetView.getBindObject().offsetLeft,
  16. c = LeadorStreetView.getBindObject().offsetTop;
  17. a || (a = { x: 0, y: 0 }), a.x += b, a.y += c, LeadorStreetView.coordinatesEvent(a) } }
  18. function ErrorReportEvent(a) { if (LeadorStreetView.errorReportEvent) { var b;
  19. a && (b = {}, b.stationID = a.StationID, b.x = a.X, b.y = a.Y, b.yaw = a.Yaw, b.pitch = a.Pitch, b.camera = a.Camera, b.citycode = a.Citycode, b.lon = a.Lon, b.lat = a.Lat, b.datatype = a.DataType, b.address = a.Address), LeadorStreetView.errorReportEvent(b) } }
  20. function openMarkerClick(a) { LeadorStreetView.createMarkerEvent && LeadorStreetView.createMarkerEvent(a) }
  21. function MarkerMouseClickEvent(a) { LeadorStreetView.markerClickEvent && LeadorStreetView.markerClickEvent(a) }
  22. function GetPreViewUrl(a) { LeadorStreetView.getPreviewFromLonlatEvent && LeadorStreetView.getPreviewFromLonlatEvent(a) }
  23. function ReSizeEvent(a, b) { LeadorStreetView.hidePoiBubble(), LeadorStreetView.reSizeEvent && LeadorStreetView.reSizeEvent(a, b) }
  24. function LoadIframe() { if (null == LeadorStreetView.iframe) { try { LeadorStreetView.iframe = document.createElement('<iframe name="leadoriframePage">') } catch (a) { LeadorStreetView.iframe = document.createElement("iframe") } LeadorStreetView.iframe.id = "leadoriframePage", LeadorStreetView.iframe.name = "leadoriframePage", LeadorStreetView.iframe.allowTransparency = "true", LeadorStreetView.iframe.style.border = "none", LeadorStreetView.iframe.frameBorder = "0", LeadorStreetView.iframe.marginwidth = "0", LeadorStreetView.iframe.marginheight = "0", LeadorStreetView.iframe.style.float = "left", LeadorStreetView.iframe.scrolling = "no", LeadorStreetView.iframe.style.position = "absolute", LeadorStreetView.iframe.style.display = "none"; for (var b = 0, c = document.getElementsByTagName("*"), d = c.length, e = 0; d > e; e++) b = Math.max(b, c[e].style.zIndex || 0);
  25. LeadorStreetView.iframe.style.zIndex = b + 1, document.body.appendChild(LeadorStreetView.iframe) } }
  26. var LeadorStreetView = function() { var a = { version: "1.3008", author: "ersu", appObject: null, visible: null, visibleUI: !0, stationID: null, yaw: null, pitch: null, isHashUpdata: !1, useHash: !0, coordinate: null, presetAngle: null, initStreetView: !0, streetViewCite: 0, swfobject: null, DIVContent: null, moreVars: null, streetViewSwf: "" + map23DConfig.map23DAssetsUrl + "/scripts/vendor/leadorStreet/TVApplication.swf", flashvars: { key: "D41D8CD98F00B204E9800998ECF8427E" }, width: "100%", height: "100%", addMarkerButtonView: null, closeButtonView: !1, fullButtonView: null, guideView: null, errorReportView: !1, autorunView: !1, compassView: null, iframe: null, bindingDIV: function(a, b, c) { if (this.DIVContent = a, this.errorEvent = b, this.moreVars = c, !this.swfobject) return this.loadScriptJs("" + map23DConfig.map23DAssetsUrl + "/scripts/vendor/leadorStreet/swfobject.js", this.loadSwfObjectEnd), void 0; if (this.streetViewCite > 0) return false/* alert("ERROR: repeat binding")*/, void 0; var d = this.getHashVar("stationID");
  27. d && (this.stationID = d); var e = this.getHashVar("yaw"); if (null != e) { var f = this.getHashVar("pitch");
  28. f = null != f ? f : 0, this.presetAngle = { yaw: e, pitch: f } } var g = "11.1.0",
  29. h = "" + map23DConfig.map23DAssetsUrl + "/scripts/vendor/leadorStreet/expressInstall.swf",
  30. i = {};
  31. i.quality = "high", i.wmode = "direct", i.bgcolor = "#ffffff", i.allowscriptaccess = "always", i.allowfullscreen = "true"; var j = {};
  32. this.streetViewCite += 1, j.id = "LeadorStreetViewApp" + this.streetViewCite, j.name = "LeadorStreetViewApp" + this.streetViewCite, j.align = "middle", c && (c.flashvars && this.setFlashvars(c.flashvars), c.swfurl && this.setStreetViewSwf(c.swfurl)), this.swfobject.embedSWF(this.streetViewSwf, a, this.width, this.height, g, h, this.flashvars, i, j, this.loadSwfEnd) }, loadSwfObjectEnd: function() { LeadorStreetView.swfobject || (LeadorStreetView.swfobject = swfobject, LeadorStreetView.bindingDIV(LeadorStreetView.DIVContent, LeadorStreetView.errorEvent, LeadorStreetView.moreVars)) }, loadScriptJs: function(a, b) { var c = document.createElement("script");
  33. c.type = "text/javascript", c.readyState ? c.onreadystatechange = function() {
  34. ("loaded" == c.readyState || "complete" == c.readyState) && (c.onreadystatechange = null, b()) } : c.onload = function() { b() }, c.src = a; var d = document.scripts[document.scripts.length - 1].parentNode;
  35. d.appendChild(c) }, removeBinding: function() { return this.initStreetView = !0, this.streetViewCite = 0, this.appObject }, loadSwfEnd: function(a) { LeadorStreetView.appObject = a.ref, null != LeadorStreetView.visible && (LeadorStreetView.visible ? LeadorStreetView.show() : LeadorStreetView.hide()), 0 == LeadorStreetView.initStreetView && FlashMapInitEnd() }, setStreetViewSwf: function(a) { this.streetViewSwf = a }, setFlashvars: function(a) { for (var b in a) this.flashvars[b] = a[b] }, setKey: function(a) { this.flashvars.key = a }, getBindObject: function() { return this.initStreetView ? null : this.appObject }, setFullScreen: function(a) { this.getBindObject().setFullScreen(a) }, getFullScreen: function() { return this.getBindObject().getFullScreen() }, loadStreetViewByID: function(a) { var b = this.getHashVar("stationID");
  36. (this.getBindObject() || !b) && (this.stationID = a, this.coordinate = [], this.initStreetView || this.getBindObject().SetTrueVisonFromID(this.stationID)) }, loadStreetViewByPosition: function(a, b) { var c = this.getHashVar("stationID");
  37. (this.getBindObject() || !c) && (this.stationID = "", this.coordinate = [a, b], this.initStreetView || this.getBindObject().SetTrueVisonFromCoordinate(this.coordinate[0], this.coordinate[1])) }, getStreetViewInfo: function() { var a = this.getBindObject().GetStationInfo(),
  38. b = {}; return b.stationID = a.StationID, b.x = a.X, b.y = a.Y, b.yaw = a.Yaw, b.pitch = a.Pitch, b.camera = a.Camera, b.citycode = a.Citycode, b.lon = a.Lon, b.lat = a.Lat, b.datatype = a.DataType, b.address = a.Address, b }, getStreetViewAngle: function() { return this.getBindObject().GetAngle() }, setStreetViewAngle: function(a, b) { this.presetAngle = a, b = 1 == b ? !0 : !1, this.getBindObject() && this.getBindObject().SetAngle(a, b) }, getZoom: function() { return this.getBindObject().GetTvZoom() }, setZoom: function(a) { this.getBindObject().SetTvZoom(a) }, setPlugin: function(a, b, c) { b = null == b ? !0 : b, c = null == c ? !0 : c, this.getBindObject() && this.getBindObject().SetPlugin(a, b, c) }, errorEvent: null, addErrorEvent: function(a) { this.errorEvent = a }, streetViewInitEndEvent: null, addInitCompleteEvent: function(a) { this.streetViewInitEndEvent = a }, streetViewCompleteEvent: null, addCompleteEvent: function(a) { this.streetViewCompleteEvent = a }, angleChangeEvent: null, addAngleChangeEvent: function(a) { this.angleChangeEvent = a }, zoomChangeEvent: null, addZoomChangeEvent: function(a) { this.zoomChangeEvent = a }, fullSrceenEvent: null, addFullSrceenEvent: function(a) { this.fullSrceenEvent = a }, plusMarkerEvent: null, addPlusMarkerEvent: function(a) { this.plusMarkerEvent = a }, streetViewCloseEvent: null, addStreetViewCloseEvent: function(a) { this.streetViewCloseEvent = a }, coordinatesEvent: null, addCoordinatesEvent: function(a) { this.coordinatesEvent = a }, errorReportEvent: null, addErrorReportEvent: function(a) { this.errorReportEvent = a }, markerClickEvent: null, addMarkerClickEvent: function(a) { this.markerClickEvent = a }, showPoiBubble: function(a) { LoadIframe(), this.iframe.src = a.src, this.iframe.width = a.width + "px", this.iframe.height = a.height + "px", this.iframe.style.top = a.top + "px", this.iframe.style.left = a.left + "px", this.iframe.style.display = "block" }, hidePoiBubble: function() { this.iframe && (this.iframe.style.display = "none") }, createMarkerEvent: null, openMarker: function(a, b) { this.createMarkerEvent = b, this.getBindObject().AddMarker(a, "openMarkerClick") }, showMarker: function(a, b) { this.addMarkerClickEvent(b), this.getBindObject().ViewMarker(a) }, deleteMarker: function(a) { this.getBindObject().DelMarker(a), this.hidePoiBubble() }, deleteAllMarker: function() { this.getBindObject().DelMarker(), this.hidePoiBubble() }, closeMarker: function() { this.getBindObject().GetClickMouseInfoEvent(null) }, hide: function() { this.visible = !1, this.appObject && (this.appObject.style.visibility = "hidden") }, show: function() { this.visible = !0, this.appObject && (this.appObject.style.visibility = "visible") }, showUI: function(a) { this.visibleUI = a, this.getBindObject() && (1 == this.visibleUI ? this.getBindObject().TVUIShow() : 0 == this.visibleUI && this.getBindObject().TVUIHide()) }, clean: function() { this.getBindObject().CleanImage() }, getPreviewFromLonlatEvent: null, getPreviewFromLonlat: function(a, b, c) { this.getPreviewFromLonlatEvent = c; var d = { lon: a, lat: b };
  39. this.getBindObject().PreviewFromLonlat(d) }, setSize: function(a) { a && (a.hasOwnProperty("width") && (this.width = a.width, this.appObject && (this.appObject.width = this.width)), a.hasOwnProperty("height") && (this.height = a.height, this.appObject && (this.appObject.height = this.height))) }, getSize: function() { return this.appObject ? { width: this.appObject.width, height: this.appObject.height } : { width: this.width, height: this.height } }, reSizeEvent: null, addReSizeEvent: function(a) { this.reSizeEvent = a }, stopAddMarker: function() {}, showMarkerUI: function(a) { this.addMarkerButtonView = a, this.getBindObject() && this.getBindObject().SetAddLableButtonView(a) }, showCloseUI: function(a) { this.closeButtonView = a, this.getBindObject() && this.getBindObject().SetBackMapButtonView(a) }, showFullScreenUI: function(a) { this.fullButtonView = a, this.getBindObject() && this.getBindObject().SetFullButtonView(a) }, showGuideUI: function(a) { this.guideView = a, this.getBindObject() && this.getBindObject().SetGuideView(a) }, showErrorReportUI: function(a) { this.errorReportView = a, this.getBindObject() && this.getBindObject().SetErrorReportView(a) }, showAutorunUI: function(a) { this.autorunView = a, this.getBindObject() && this.getBindObject().SetAutorunView(a) }, showCompassUI: function(a) { this.compassView = a, this.getBindObject() && this.getBindObject().SetCompassView(a) }, getScreenshot: function(a, b) { this.getBindObject() && this.getBindObject().GetScreenshot(a, b) }, getHrefVar: function(a) { return this.getQueryString(a, "href") }, getHashVar: function(a) { return this.getQueryString(a, "hash") }, onhashchangeEvent: function() { if (LeadorStreetView.isHashUpdata) return LeadorStreetView.isHashUpdata = !1, void 0; var a = LeadorStreetView.getHashVar("stationID"),
  40. b = LeadorStreetView.getHashVar("yaw"),
  41. c = LeadorStreetView.getHashVar("pitch");
  42. a && (a != LeadorStreetView.stationID && LeadorStreetView.loadStreetViewByID(a), null == b || b == LeadorStreetView.yaw && c == LeadorStreetView.pitch || LeadorStreetView.setStreetViewAngle({ yaw: b, pitch: c })) }, getQueryString: function(a, b) { var c; if ("href" == b) { if (-1 == location.href.indexOf("?") || -1 == location[b].indexOf(a + "=")) return null;
  43. c = location.href.substring(location.href.indexOf("?") + 1) } else { if ("hash" != b) return null;
  44. c = location.href.substring(location.href.indexOf("#") + 1) } for (var e, f, g, d = c.split("&"), h = 0; h < d.length; h++)
  45. if (e = d[h].indexOf("="), -1 != e && (f = d[h].substring(0, e), g = d[h].substring(e + 1), f == a)) return unescape(g.replace(/\+/g, " ")); return null } }; return a }();