1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
-
- var BMapLib = window.BMapLib = BMapLib || {};
- (function () {
-
- var T,
- baidu = T = baidu || {version: "1.3.8"};
- (function (){
-
-
- baidu.guid = "$BAIDU$";
-
-
- window[baidu.guid] = window[baidu.guid] || {};
-
- baidu.dom = baidu.dom || {};
-
- baidu.dom.g = function (id) {
- if ('string' == typeof id || id instanceof String) {
- return document.getElementById(id);
- } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) {
- return id;
- }
- return null;
- };
-
- baidu.g = baidu.G = baidu.dom.g;
-
- baidu.dom.getDocument = function (element) {
- element = baidu.dom.g(element);
- return element.nodeType == 9 ? element : element.ownerDocument || element.document;
- };
-
- baidu.lang = baidu.lang || {};
-
- baidu.lang.isString = function (source) {
- return '[object String]' == Object.prototype.toString.call(source);
- };
-
- baidu.isString = baidu.lang.isString;
-
- baidu.dom._g = function (id) {
- if (baidu.lang.isString(id)) {
- return document.getElementById(id);
- }
- return id;
- };
-
- baidu._g = baidu.dom._g;
-
- baidu.browser = baidu.browser || {};
- if (/msie (\d+\.\d)/i.test(navigator.userAgent)) {
-
-
-
- baidu.browser.ie = baidu.ie = document.documentMode || + RegExp['\x241'];
- }
-
- baidu.dom.getComputedStyle = function(element, key){
- element = baidu.dom._g(element);
- var doc = baidu.dom.getDocument(element),
- styles;
- if (doc.defaultView && doc.defaultView.getComputedStyle) {
- styles = doc.defaultView.getComputedStyle(element, null);
- if (styles) {
- return styles[key] || styles.getPropertyValue(key);
- }
- }
- return '';
- };
-
- baidu.dom._styleFixer = baidu.dom._styleFixer || {};
-
- baidu.dom._styleFilter = baidu.dom._styleFilter || [];
-
- baidu.dom._styleFilter.filter = function (key, value, method) {
- for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) {
- if (filter = filter[method]) {
- value = filter(key, value);
- }
- }
- return value;
- };
-
- baidu.string = baidu.string || {};
-
- baidu.string.toCamelCase = function (source) {
-
- if (source.indexOf('-') < 0 && source.indexOf('_') < 0) {
- return source;
- }
- return source.replace(/[-_][^-_]/g, function (match) {
- return match.charAt(1).toUpperCase();
- });
- };
-
- baidu.dom.getStyle = function (element, key) {
- var dom = baidu.dom;
- element = dom.g(element);
- key = baidu.string.toCamelCase(key);
-
- var value = element.style[key] ||
- (element.currentStyle ? element.currentStyle[key] : "") ||
- dom.getComputedStyle(element, key);
-
- if (!value) {
- var fixer = dom._styleFixer[key];
- if(fixer){
- value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer);
- }
- }
-
- if (fixer = dom._styleFilter) {
- value = fixer.filter(key, value, 'get');
- }
- return value;
- };
-
- baidu.getStyle = baidu.dom.getStyle;
- if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) {
-
- baidu.browser.opera = + RegExp['\x241'];
- }
-
- baidu.browser.isWebkit = /webkit/i.test(navigator.userAgent);
-
- baidu.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent);
-
- baidu.browser.isStrict = document.compatMode == "CSS1Compat";
-
- baidu.dom.getPosition = function (element) {
- element = baidu.dom.g(element);
- var doc = baidu.dom.getDocument(element),
- browser = baidu.browser,
- getStyle = baidu.dom.getStyle,
-
-
-
-
- BUGGY_GECKO_BOX_OBJECT = browser.isGecko > 0 &&
- doc.getBoxObjectFor &&
- getStyle(element, 'position') == 'absolute' &&
- (element.style.top === '' || element.style.left === ''),
- pos = {"left":0,"top":0},
- viewport = (browser.ie && !browser.isStrict) ? doc.body : doc.documentElement,
- parent,
- box;
- if(element == viewport){
- return pos;
- }
- if(element.getBoundingClientRect){
-
-
- box = element.getBoundingClientRect();
- pos.left = Math.floor(box.left) + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
- pos.top = Math.floor(box.top) + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
-
-
-
-
-
- pos.left -= doc.documentElement.clientLeft;
- pos.top -= doc.documentElement.clientTop;
- var htmlDom = doc.body,
-
- htmlBorderLeftWidth = parseInt(getStyle(htmlDom, 'borderLeftWidth')),
- htmlBorderTopWidth = parseInt(getStyle(htmlDom, 'borderTopWidth'));
- if(browser.ie && !browser.isStrict){
- pos.left -= isNaN(htmlBorderLeftWidth) ? 2 : htmlBorderLeftWidth;
- pos.top -= isNaN(htmlBorderTopWidth) ? 2 : htmlBorderTopWidth;
- }
- } else {
-
- parent = element;
- do {
- pos.left += parent.offsetLeft;
- pos.top += parent.offsetTop;
-
- if (browser.isWebkit > 0 && getStyle(parent, 'position') == 'fixed') {
- pos.left += doc.body.scrollLeft;
- pos.top += doc.body.scrollTop;
- break;
- }
- parent = parent.offsetParent;
- } while (parent && parent != element);
-
- if(browser.opera > 0 || (browser.isWebkit > 0 && getStyle(element, 'position') == 'absolute')){
- pos.top -= doc.body.offsetTop;
- }
-
- parent = element.offsetParent;
- while (parent && parent != doc.body) {
- pos.left -= parent.scrollLeft;
-
- if (!browser.opera || parent.tagName != 'TR') {
- pos.top -= parent.scrollTop;
- }
- parent = parent.offsetParent;
- }
- }
- return pos;
- };
-
- baidu.event = baidu.event || {};
-
- baidu.event._listeners = baidu.event._listeners || [];
-
- baidu.event.on = function (element, type, listener) {
- type = type.replace(/^on/i, '');
- element = baidu.dom._g(element);
- var realListener = function (ev) {
-
-
- listener.call(element, ev);
- },
- lis = baidu.event._listeners,
- filter = baidu.event._eventFilter,
- afterFilter,
- realType = type;
- type = type.toLowerCase();
-
- if(filter && filter[type]){
- afterFilter = filter[type](element, type, realListener);
- realType = afterFilter.type;
- realListener = afterFilter.listener;
- }
-
-
- if (element.addEventListener) {
- element.addEventListener(realType, realListener, false);
- } else if (element.attachEvent) {
- element.attachEvent('on' + realType, realListener);
- }
-
- lis[lis.length] = [element, type, listener, realListener, realType];
-
- return element;
- };
-
- baidu.on = baidu.event.on;
-
- (function(){
-
- var guid = window[baidu.guid];
- baidu.lang.guid = function() {
- return "TANGRAM__" + (guid._counter ++).toString(36);
- };
- guid._counter = guid._counter || 1;
- })();
-
- window[baidu.guid]._instances = window[baidu.guid]._instances || {};
-
- baidu.lang.isFunction = function (source) {
-
- return '[object Function]' == Object.prototype.toString.call(source);
- };
-
- baidu.lang.Class = function(guid) {
- this.guid = guid || baidu.lang.guid();
- window[baidu.guid]._instances[this.guid] = this;
- };
- window[baidu.guid]._instances = window[baidu.guid]._instances || {};
-
- baidu.lang.Class.prototype.dispose = function(){
- delete window[baidu.guid]._instances[this.guid];
- for(var property in this){
- if (!baidu.lang.isFunction(this[property])) {
- delete this[property];
- }
- }
- this.disposed = true;
- };
-
- baidu.lang.Class.prototype.toString = function(){
- return "[object " + (this._className || "Object" ) + "]";
- };
-
- baidu.lang.Event = function (type, target) {
- this.type = type;
- this.returnValue = true;
- this.target = target || null;
- this.currentTarget = null;
- };
-
- baidu.lang.Class.prototype.addEventListener = function (type, handler, key) {
- if (!baidu.lang.isFunction(handler)) {
- return;
- }
- !this.__listeners && (this.__listeners = {});
- var t = this.__listeners, id;
- if (typeof key == "string" && key) {
- if (/[^\w\-]/.test(key)) {
- throw("nonstandard key:" + key);
- } else {
- handler.hashCode = key;
- id = key;
- }
- }
- type.indexOf("on") != 0 && (type = "on" + type);
- typeof t[type] != "object" && (t[type] = {});
- id = id || baidu.lang.guid();
- handler.hashCode = id;
- t[type][id] = handler;
- };
-
- baidu.lang.Class.prototype.removeEventListener = function (type, handler) {
- if (typeof handler != "undefined") {
- if ( (baidu.lang.isFunction(handler) && ! (handler = handler.hashCode))
- || (! baidu.lang.isString(handler))
- ){
- return;
- }
- }
- !this.__listeners && (this.__listeners = {});
- type.indexOf("on") != 0 && (type = "on" + type);
- var t = this.__listeners;
- if (!t[type]) {
- return;
- }
- if (typeof handler != "undefined") {
- t[type][handler] && delete t[type][handler];
- } else {
- for(var guid in t[type]){
- delete t[type][guid];
- }
- }
- };
-
- baidu.lang.Class.prototype.dispatchEvent = function (event, options) {
- if (baidu.lang.isString(event)) {
- event = new baidu.lang.Event(event);
- }
- !this.__listeners && (this.__listeners = {});
-
- options = options || {};
- for (var i in options) {
- event[i] = options[i];
- }
- var i, t = this.__listeners, p = event.type;
- event.target = event.target || this;
- event.currentTarget = this;
- p.indexOf("on") != 0 && (p = "on" + p);
- baidu.lang.isFunction(this[p]) && this[p].apply(this, arguments);
- if (typeof t[p] == "object") {
- for (i in t[p]) {
- t[p][i].apply(this, arguments);
- }
- }
- return event.returnValue;
- };
- baidu.lang.inherits = function (subClass, superClass, className) {
- var key, proto,
- selfProps = subClass.prototype,
- clazz = new Function();
- clazz.prototype = superClass.prototype;
- proto = subClass.prototype = new clazz();
- for (key in selfProps) {
- proto[key] = selfProps[key];
- }
- subClass.prototype.constructor = subClass;
- subClass.superClass = superClass.prototype;
-
- if ("string" == typeof className) {
- proto._className = className;
- }
- };
-
- baidu.inherits = baidu.lang.inherits;
- })();
-
- var _IMAGE_PATH = './img/blue';
-
- var _IMAGE_EXTENSION = 'png';
-
- var TextIconOverlay =
-
- BMapLib.TextIconOverlay = function(position, text, options){
- this._position = position;
- this._text = text;
- this._options = options || {};
- this._styles = this._options['styles'] || [];
- (!this._styles.length) && this._setupDefaultStyles();
- };
- T.lang.inherits(TextIconOverlay, BMap.Overlay, "TextIconOverlay");
- TextIconOverlay.prototype._setupDefaultStyles = function(){
-
-
-
-
- this._styles.push({
- url:_IMAGE_PATH + '.' + _IMAGE_EXTENSION,
- size: new BMap.Size(92, 92)
- });
-
- };
-
- TextIconOverlay.prototype.initialize = function(map){
- this._map = map;
- this._domElement = document.createElement('div');
- this._updateCss();
- this._updateText();
- this._updatePosition();
- this._bind();
- this._map.getPanes().markerMouseTarget.appendChild(this._domElement);
- return this._domElement;
- };
-
- TextIconOverlay.prototype.draw = function(){
- this._map && this._updatePosition();
- };
-
- TextIconOverlay.prototype.getText = function(){
- return this._text;
- };
-
- TextIconOverlay.prototype.setText = function(text){
- if(text && (!this._text || (this._text.value != text.value) || (this._text.name != text.name))){
- this._text = text;
- this._updateText();
- this._updateCss();
- this._updatePosition();
- }
- };
-
- TextIconOverlay.prototype.getPosition = function () {
- return this._position;
- };
-
- TextIconOverlay.prototype.setPosition = function (position) {
- if(position && (!this._position || !this._position.equals(position))){
- this._position = position;
- this._updatePosition();
- }
- };
-
-
-
-
-
-
-
-
-
- TextIconOverlay.prototype._updateCss = function(){
-
- var style = this._styles[0];
- this._domElement.style.cssText = this._buildCssText(style);
- };
-
- TextIconOverlay.prototype._updateText = function(){
- if (this._domElement) {
- this._domElement.innerHTML = '<p style="margin-top:25px;width:75px;margin-left:9px;line-height:15px;">'+this._text.name+'</p>'+'<p>'+this._text.value+'</p>';
- }
- };
-
- TextIconOverlay.prototype._updatePosition = function(){
- if (this._domElement && this._position) {
- var style = this._domElement.style;
- var pixelPosition= this._map.pointToOverlayPixel(this._position);
- pixelPosition.x -= Math.ceil(parseInt(style.width) / 2);
- pixelPosition.y -= Math.ceil(parseInt(style.height) / 2);
- style.left = pixelPosition.x + "px";
- style.top = pixelPosition.y + "px";
- }
- };
-
- TextIconOverlay.prototype._buildCssText = function(style) {
-
- var url = style['url'];
- var size = style['size'];
- var anchor = style['anchor'];
- var offset = style['offset'];
- var textColor = style['textColor'] || '#fff';
- var textSize = style['textSize'] || 10;
- var csstext = [];
- if (T.browser["ie"] < 7) {
- csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(' +
- 'sizingMethod=scale,src="' + url + '");')
- } else {
- csstext.push('background-image:url(' + url + ');');
- var backgroundPosition = '0 0';
- (offset instanceof BMap.Size) && (backgroundPosition = offset.width + 'px' + ' ' + offset.height + 'px');
- csstext.push('background-position:' + backgroundPosition + ';');
- }
- if (size instanceof BMap.Size){
- if (anchor instanceof BMap.Size) {
- if (anchor.height > 0 && anchor.height < size.height) {
- csstext.push('height:' + (size.height - anchor.height) + 'px; padding-top:' + anchor.height + 'px;');
- }
- if(anchor.width > 0 && anchor.width < size.width){
- csstext.push('width:' + (size.width - anchor.width) + 'px; padding-left:' + anchor.width + 'px;');
- }
- } else {
- csstext.push('height:' + size.height + 'px; line-height:' + 20 + 'px;');
- csstext.push('width:' + size.width + 'px; text-align:center;');
- }
- }
- csstext.push('cursor:pointer; color:' + textColor + '; position:absolute; font-size:' +
- textSize + 'px; font-family:Arial,sans-serif; font-weight:bold');
- return csstext.join('');
- };
-
-
-
-
- TextIconOverlay.prototype._bind = function(){
- if (!this._domElement){
- return;
- }
- var me = this;
- var map = this._map;
- var BaseEvent = T.lang.Event;
- function eventExtend(e, be){
- var elem = e.srcElement || e.target;
- var x = e.clientX || e.pageX;
- var y = e.clientY || e.pageY;
- if (e && be && x && y && elem){
- var offset = T.dom.getPosition(map.getContainer());
- be.pixel = new BMap.Pixel(x - offset.left, y - offset.top);
- be.point = map.pixelToPoint(be.pixel);
- }
- return be;
- }
- T.event.on(this._domElement,"mouseover", function(e){
- me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseover")));
- });
- T.event.on(this._domElement,"mouseout", function(e){
- me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseout")));
- });
- T.event.on(this._domElement,"click", function(e){
- me.dispatchEvent(eventExtend(e, new BaseEvent("onclick")));
- });
- };
- })();
|