📄 mapstraction.js
字号:
this.sw.lon = point.lon; if(this.ne.lat < point.lat)this.ne.lat = point.lat; if(this.ne.lon < point.lon)this.ne.lon = point.lon; return;}function Marker(point) { this.gmarker=null; this.location = point; this.onmap = false; this.proprietary_marker = false; this.attributes = new Array(); this.pinID = "mspin-"+new Date().getTime()+'-'+(Math.floor(Math.random()*Math.pow(2,16)));}Marker.prototype.setChild = function(some_proprietary_marker) { this.proprietary_marker = some_proprietary_marker; this.onmap = true}Marker.prototype.setLabel = function(labelText) { this.labelText = labelText;}Marker.prototype.addData = function(options){ if(options.label)this.setLabel(options.label); if(options.infoBubble)this.setInfoBubble(options.infoBubble); if(options.icon) { if(options.iconSize)this.setIcon(options.icon, new Array(options.iconSize[0], options.iconSize[1])); elsethis.setIcon(options.icon); if(options.iconAnchor)this.setIconAnchor(new Array(options.iconAnchor[0], options.iconAnchor[1]));}if(options.iconShadow) { if(options.iconShadowSize)this.setShadowIcon(options.iconShadow, new Array(options.iconShadowSize[0], options.iconShadowSize[1])); elsethis.setIcon(options.iconShadow);}if(options.infoDiv)this.setInfoDiv(options.infoDiv[0],options.infoDiv[1]); if(options.draggable)this.setDraggable(options.draggable); if(options.hover)this.setHover(options.hover); if(options.hoverIcon)this.setHoverIcon(options.hoverIcon); if(options.openBubble)this.openBubble(); if(options.date)this.setAttribute( 'date', eval(options.date) ); if(options.category)this.setAttribute( 'category', options.category );}Marker.prototype.setInfoBubble = function(infoBubble) { this.infoBubble = infoBubble;}Marker.prototype.setInfoDiv = function(infoDiv,div){ this.infoDiv = infoDiv; this.div = div;}Marker.prototype.setIcon = function(iconUrl, iconSize, iconAnchor){ this.iconUrl = iconUrl; if(iconSize)this.iconSize = iconSize; if(iconAnchor)this.iconAnchor = iconAnchor;}Marker.prototype.setIconSize = function(iconSize){ if(iconSize)this.iconSize = iconSize;}Marker.prototype.setIconAnchor = function(iconAnchor){ if(iconAnchor)this.iconAnchor = iconAnchor;}Marker.prototype.setShadowIcon = function(iconShadowUrl, iconShadowSize){ this.iconShadowUrl = iconShadowUrl; if(iconShadowSize)this.iconShadowSize = iconShadowSize;}Marker.prototype.setHoverIcon = function(hoverIconUrl){ this.hoverIconUrl = hoverIconUrl;}Marker.prototype.setDraggable = function(draggable) { this.draggable = draggable;}Marker.prototype.setHover = function(hover) { this.hover = hover;}Marker.prototype.changeIcon = function(iconUrl) { if (this.proprietary_marker) { this.proprietary_marker.setImage(iconUrl);}}Marker.prototype.revertIcon = function() { this.changeIcon(this.iconUrl);}Marker.prototype.toYahoo = function() { var ymarker; if(this.iconUrl) { ymarker = new YMarker(this.location.toYahoo (),new YImage(this.iconUrl));} else { ymarker = new YMarker(this.location.toYahoo());}if(this.iconSize) { ymarker.size = new YSize(this.iconSize[0], this.iconSize[1]);}if(this.labelText) { ymarker.addLabel(this.labelText);}if(this.infoBubble) { var theInfo = this.infoBubble; var event_action; if(this.hover) { event_action = EventsList.MouseOver;}else { event_action = EventsList.MouseClick;}YEvent.Capture(ymarker, event_action, function() { ymarker.openSmartWindow(theInfo);});}if(this.infoDiv) { var theInfo = this.infoDiv; var div = this.div; var event_div; if(this.hover) { event_action = EventsList.MouseOver;}else { event_action = EventsList.MouseClick;}YEvent.Capture(ymarker, event_action, function() { document.getElementById(div).innerHTML = theInfo;});}return ymarker;}Marker.prototype.toGoogle = function() { if(this.gmarker) {return this.gmarker;} var options = new Object(); if(this.labelText) { options.title = this.labelText;}if(this.iconUrl){ var icon = new GIcon(G_DEFAULT_ICON,this.iconUrl); if(this.iconSize) { icon.iconSize = new GSize(this.iconSize[0], this.iconSize[1]); var anchor; if(this.iconAnchor) { anchor = new GPoint(this.iconAnchor[0], this.iconAnchor[1]);}else { anchor = new GPoint(this.iconSize[0]/2, this.iconSize[1]/2);}icon.iconAnchor = anchor;}if(this.iconShadowUrl) { icon.shadow = this.iconShadowUrl; if(this.iconShadowSize) { icon.shadowSize = new GSize(this.iconShadowSize[0], this.iconShadowSize[1]);}}options.icon = icon;}if(this.draggable){ options.draggable = this.draggable;}this.gmarker = new GMarker( this.location.toGoogle(),options); var gmarker = this.gmarker; if(this.infoBubble) { var theInfo = this.infoBubble; var event_action; if(this.hover) { event_action = "mouseover";}else { event_action = "click";}GEvent.addListener(this.gmarker, event_action, function() { gmarker.openInfoWindowHtml(theInfo, {maxWidth: 100});});}if(this.hoverIconUrl) { GEvent.addListener(this.gmarker, "mouseover", function() { gmarker.setImage(this.hoverIconUrl);}); GEvent.addListener(this.gmarker, "mouseout", function() {gmarker.setImage(this.iconUrl);});}if(this.infoDiv){ var theInfo = this.infoDiv; var div = this.div; var event_action; if(this.hover) { event_action = "mouseover";}else { event_action = "click";}GEvent.addListener(this.gmarker, event_action, function() { document.getElementById(div).innerHTML = theInfo;});}return this.gmarker;}Marker.prototype.toOpenLayers = function() { if(this.iconSize) { var size = new OpenLayers.Size(this.iconSize[0], this.iconSize[1]);}else{ var size = new OpenLayers.Size(15,20);}if(this.iconAnchor){ var anchor = new OpenLayers.Pixel(this.iconAnchor[0], this.iconAnchor[1]);}else{ anchor = new OpenLayers.Pixel(-(size.w/2), -size.h);}if(this.iconUrl) { var icon = new OpenLayers.Icon(this.iconUrl, size, anchor);}else{ var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png', size, anchor);}var marker = new OpenLayers.Marker(this.location.toOpenLayers(), icon); return marker;}Marker.prototype.toMicrosoft = function() { var pin = new VEPushpin(this.pinID,this.location.toMicrosoft(), this.iconUrl,this.labelText,this.infoBubble); return pin;}Marker.prototype.toMap24 = function() { var ops = new Object(); ops.Longitude = this.location.lon*60; ops.Latitude = this.location.lat*60; if(this.infoBubble) { ops.TooltipContent = this.infoBubble;}if(this.labelText) { }ops.LogoURL = this.iconUrl ? this.iconUrl :"http://www.free-map.org.uk/images/marker.png"; ops.TooltipLayout = Map24.MapObject.LAYOUT_BUBBLE; if(this.hover) { ops.TooltipOpen = "OnMouseOver";} else { ops.TooltipOpen = "OnClick";}var m24Location = new Map24.Location ( ops ); return m24Location;}Marker.prototype.toMultiMap = function() { if (this.iconUrl) { var icon = new MMIcon(this.iconUrl); icon.iconSize = new MMDimensions(32, 32); var mmmarker = new MMMarkerOverlay( this.location.toMultiMap(), {'icon' : icon} );} else { var mmmarker = new MMMarkerOverlay( this.location.toMultiMap());}if(this.labelText){ }if(this.infoBubble) { mmmarker.setInfoBoxContent(this.infoBubble);}if(this.infoDiv) { }for (var key in this.attributes) { mmmarker.setAttribute(key, this.attributes[ key ]);}return mmmarker;}Marker.prototype.toMapQuest = function() { var mqmarker = new MQPoi( this.location.toMapQuest() ); if(this.iconUrl){ var mqicon = new MQMapIcon(); mqicon.setImage(this.iconUrl,32,32,true,false); mqmarker.setIcon(mqicon);}if(this.labelText) { mqmarker.setInfoTitleHTML( this.labelText );}if(this.infoBubble) { mqmarker.setInfoContentHTML( this.infoBubble );}if(this.infoDiv){ var theInfo = this.infoDiv; var div = this.div; MQEventManager.addListener(mqmarker, "click", function() { document.getElementById(div).innerHTML = theInfo;});}return mqmarker;}Marker.prototype.toFreeEarth = function() { var feicon; if (this.iconUrl) { feicon = new FE.Icon(this.iconUrl);} else { feicon = new FE.Icon("http://freeearth.poly9.com/images/bullmarker.png");}var femarker = new FE.Pushpin( this.location.toFreeEarth(), feicon); if(this.infoBubble) { var theBubble = this.infoBubble; FE.Event.addListener(femarker, 'click', function() { femarker.openInfoWindowHtml( theBubble, 200, 100 );} );}if(this.infoDiv) { var theInfo = this.infoDiv; var div = this.div; FE.Event.addListener(femarker, 'click', function() { document.getElementById(div).innerHTML = theInfo;});}return femarker;}Marker.prototype.setAttribute = function(key,value) { this.attributes[key] = value;}Marker.prototype.getAttribute = function(key) { return this.attributes[key];}Marker.prototype.openBubble = function() { if(this.mapstraction.loaded[this.api] == false) { var my_marker = this; this.mapstraction.onload[this.api].push( function() { my_marker.openBubble();} ); return;}if( this.api) { switch (this.api) { case 'yahoo':var ypin = this.proprietary_marker; ypin.openSmartWindow(this.infoBubble); break; case 'google':case 'openstreetmap':var gpin = this.proprietary_marker; gpin.openInfoWindowHtml(this.infoBubble); break; case 'microsoft':var pin = this.proprietary_marker; var el = $m(this.pinID + "_" + this.maps[this.api].GUID).onmouseover; setTimeout(el, 1000); break; case 'multimap':this.proprietary_marker.openInfoBox(); break; case 'mapquest':this.proprietary_marker.setRolloverEnabled(false); this.proprietary_marker.showInfoWindow(); this.proprietary_marker.setRolloverEnabled(true); break;}} else { alert('You need to add the marker before opening it');}}Marker.prototype.hide = function() { if (this.api) { switch (this.api) { case 'google':case 'openstreetmap':this.proprietary_marker.hide(); break; case 'openlayers':this.proprietary_marker.display(false); break; case 'yahoo':this.proprietary_marker.hide(); break; case 'map24':this.proprietary_marker.hide(); break; case 'multimap':this.proprietary_marker.setVisibility(false); break; case 'mapquest':this.proprietary_marker.setVisible(false); break; default:if(this.debug)alert(this.api + "not supported by Marker.hide");}}}Marker.prototype.show = function() { if (this.api) { switch (this.api) { case 'google':case 'openstreetmap':this.proprietary_marker.show(); break; case 'openlayers':this.proprietary_marker.display(true); break; case 'map24':this.proprietary_marker.show(); break; case 'yahoo':this.proprietary_marker.unhide(); break; case 'multimap':this.proprietary_marker.setVisibility(true); break; case 'mapquest':this.proprietary_marker.setVisible(true); break; default:if(this.debug)alert(this.api + "not supported by Marker.show");}}}function Polyline(points) { this.points = points; this.attributes = new Array(); this.onmap = false; this.proprietary_polyline = false; this.pllID = "mspll-"+new Date().getTime()+'-'+(Math.floor(Math.random()*Math.pow(2,16)));}Polyline.prototype.addData = function(options){ if(options.color)this.setColor(options.color); if(options.width)this.setWidth(options.width); if(options.opacity)this.setIcon(options.opacity); if(options.date)this.setAttribute( 'date', eval(options.date) ); if(options.category)this.setAttribute( 'category', options.category );}Polyline.prototype.setChild = function(some_proprietary_polyline) { this.proprietary_polyline = some_proprietary_polyline; this.onmap = true;}Polyline.prototype.setColor = function(color){ this.color = (color.length==7 && color[0]=="#") ? color.toUpperCase() : color;}Polyline.prototype.setWidth = function(width){ this.width = width;}Polyline.prototype.setOpacity = function(opacity){ this.opacity = opacity;}Polyline.prototype.toYahoo = function() { var ypolyline; var ypoints = []; for (var i = 0, length = this.points.length ; i< length; i++){ ypoints.push(this.points[i].toYahoo());}ypolyline = new YPolyline(ypoints,this.color,this.width,this.opacity); return ypolyline;}Polyline.prototype.toGoogle = function() { var gpolyline; var gpoints = []; for (var i = 0, length = this.points.length ; i< length; i++){ gpoints.push(this.points[i].toGoogle());}gpolyline = new GPolyline(gpoints,this.color,this.width,this.opacity); return gpolyline;}Polyline.prototype.toMap24 = function() { var m24polyline; var m24longs = ""; var m24lats = ""; for (var i=0; i<this.points.length; i++) { if(i) { m24longs += "|"; m24lats += "|";}m24longs += (this.points[i].lon*60); m24lats +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -