📄 mapstraction.js
字号:
break; case 'microsoft':map.DeleteAllPolylines(); break; case 'multimap':for(var i = 0, length = this.polylines.length;i < length;i++){ this.polylines[i].proprietary_polyline.remove();}break; case 'mapquest':map.removeAllOverlays(); break; case 'map24':var current_polyline; while(this.polylines.length > 0) { current_polyline = this.polylines.pop(); current_polyline.proprietary_polyline.remove();}break; default:if(this.debug)alert(this.api + ' not supported by Mapstraction.removeAllPolylines');}this.polylines = new Array();}Mapstraction.prototype.getCenter = function() { if(this.loaded[this.api] == false) { return null;}var map = this.maps[this.api]; var point = undefined; switch (this.api) { case 'yahoo':var pt = map.getCenterLatLon(); point = new LatLonPoint(pt.Lat,pt.Lon); break; case 'google':case 'openstreetmap':var pt = map.getCenter(); point = new LatLonPoint(pt.lat(),pt.lng()); break; case 'openlayers':var pt = map.getCenter(); point = new LatLonPoint(pt.lat, pt.lon); break; case 'microsoft':var pt = map.GetCenter(); point = new LatLonPoint(pt.Latitude,pt.Longitude); break; case 'multimap':var pt = map.getCurrentPosition(); point = new LatLonPoint(pt.y, pt.x); break; case 'mapquest':var pt = map.getCenter(); point = new LatLonPoint(pt.getLatitude(), pt.getLongitude()); break; case 'map24':var pt = map.MapClient['Static'].getCurrentMapView().getCenter(); point = new LatLonPoint(pt.Y/60,pt.X/60); break; default:if(this.debug)alert(this.api + ' not supported by Mapstraction.getCenter');}return point;}Mapstraction.prototype.setCenter = function(point) { if(this.loaded[this.api] == false) { myself = this; this.onload[this.api].push( function() { myself.setCenter(point);} ); return;}var map = this.maps[this.api]; switch (this.api) { case 'yahoo':map.panToLatLon(point.toYahoo()); break; case 'google':case 'openstreetmap':map.setCenter(point.toGoogle()); break; case 'openlayers':map.setCenter(point.toOpenLayers()); break; case 'microsoft':map.SetCenter(point.toMicrosoft()); break; case 'multimap':map.goToPosition(point.toMultiMap()); break; case 'mapquest':map.setCenter(point.toMapQuest()); break; case 'freeearth':if (this.freeEarthLoaded) { map.setTargetLatLng( point.toFreeEarth() );} else { myself = this; this.freeEarthOnLoad.push( function() { myself.setCenterAndZoom(point);} );}break; case 'map24':var mv = map.MapClient['Static'].getCurrentMapView(); var newSettings = new Object(); newSettings.MinimumWidth = lonToMetres(mv.LowerRight.Longitude - mv.TopLeft.Longitude, (mv.LowerRight.Latitude+mv.TopLeft.Latitude)/2); newSettings.Latitude = point.lat*60; newSettings.Longitude = point.lon*60; Map24.MapApplication.center(newSettings); break; default:if(this.debug)alert(this.api + ' not supported by Mapstraction.setCenter');}}Mapstraction.prototype.setZoom = function(zoom) { if(this.loaded[this.api] == false) { myself = this; this.onload[this.api].push( function() { myself.setZoom(zoom);} ); return;}var map = this.maps[this.api]; switch (this.api) { case 'yahoo':var yzoom = 18 - zoom; map.setZoomLevel(yzoom); break; case 'google':case 'openstreetmap':map.setZoom(zoom); break; case 'openlayers':map.zoomTo(zoom); break; case 'microsoft':map.SetZoomLevel(zoom); break; case 'multimap':map.setZoomFactor(zoom); break; case 'mapquest':map.setZoomLevel(zoom - 3); break; case 'map24':var point = this.getCenter(); var newSettings = new Object(); newSettings.Latitude = point.lat*60; newSettings.Longitude = point.lon*60; var client = map.MapClient['Static']; var dLon = getDegreesFromGoogleZoomLevel(client.getCanvasSize().Width,zoom); newSettings.MinimumWidth = lonToMetres (dLon, point.lat); Map24.MapApplication.center ( newSettings ); break; default:if(this.debug)alert(this.api + ' not supported by Mapstraction.setZoom');}}Mapstraction.prototype.autoCenterAndZoom = function() { if(this.loaded[this.api] == false) { myself = this; this.onload[this.api].push( function() { myself.autoCenterAndZoom();} ); return;}var lat_max = -90; var lat_min = 90; var lon_max = -180; var lon_min = 180; for (var i=0; i<this.markers.length; i++) {; lat = this.markers[i].location.lat; lon = this.markers[i].location.lon; if (lat > lat_max) lat_max = lat; if (lat < lat_min) lat_min = lat; if (lon > lon_max) lon_max = lon; if (lon < lon_min) lon_min = lon;}for (i=0; i<this.polylines.length; i++) { for (j=0; j<this.polylines[i].points.length; j++) { lat = this.polylines[i].points[j].lat; lon = this.polylines[i].points[j].lon; if (lat > lat_max) lat_max = lat; if (lat < lat_min) lat_min = lat; if (lon > lon_max) lon_max = lon; if (lon < lon_min) lon_min = lon;}}this.setBounds( new BoundingBox(lat_min, lon_min, lat_max, lon_max) );}Mapstraction.prototype.centerAndZoomOnPoints = function(points) { var bounds = new BoundingBox(points[0].lat,points[0].lon,points[0].lat,points[0].lon); for (var i=1, len = points.length ; i<len; i++) { bounds.extend(points[i]);}this.setBounds(bounds);}Mapstraction.prototype.getZoom = function() { if(this.loaded[this.api] == false) { myself = this; return -1;}var map = this.maps[this.api]; switch (this.api) { case 'yahoo':return 18 - map.getZoomLevel(); case 'google':case 'openstreetmap':return map.getZoom(); case 'openlayers':return map.zoom; case 'microsoft':return map.GetZoomLevel(); case 'multimap':return map.getZoomFactor(); case 'mapquest':return map.getZoomLevel() + 3; case 'map24':var mv = map.MapClient['Static'].getCurrentMapView(); var dLon = (mv.LowerRight.Longitude - mv.TopLeft.Longitude) / 60; var width = map.MapClient['Static'].getCanvasSize().Width; var zoom = getGoogleZoomLevelFromDegrees (width,dLon); return Math.round(zoom); default:if(this.debug)alert(this.api + ' not supported by Mapstraction.getZoom');}}Mapstraction.prototype.getZoomLevelForBoundingBox = function( bbox ) { if(this.loaded[this.api] == false) { myself = this; return -1;}var map = this.maps[this.api]; var ne = bbox.getNorthEast(); var sw = bbox.getSouthWest(); switch (this.api) { case 'google':case 'openstreetmap':var gbox = new GLatLngBounds( sw.toGoogle(), ne.toGoogle() ); var zoom = map.getBoundsZoomLevel( gbox ); return zoom; break; case 'openlayers':var olbox = bbox.toOpenLayers(); var zoom = map.getZoomForExtent(olbox); break; case 'multimap':var mmlocation = map.getBoundsZoomFactor( sw.toMultiMap(), ne.toMultiMap() ); var zoom = mmlocation.zoom_factor(); return zoom; break; case 'map24':var dLon = ne.lon - sw.lon; var width = map.MapClient['Static'].getCanvasSize().Width; var zoom = getGoogleZoomLevelFromDegrees (width,dLon); return Math.round(zoom); break; default:if(this.debug)alert( this.api + ' not supported by Mapstraction.getZoomLevelForBoundingBox' );}}Mapstraction.ROAD = 1; Mapstraction.SATELLITE = 2; Mapstraction.HYBRID = 3; Mapstraction.prototype.setMapType = function(type) { if(this.loaded[this.api] == false) { myself = this; this.onload[this.api].push( function() { myself.setMapType(type);} ); return;}var map = this.maps[this.api]; switch (this.api) { case 'yahoo':switch(type) { case Mapstraction.ROAD:map.setMapType(YAHOO_MAP_REG); break; case Mapstraction.SATELLITE:map.setMapType(YAHOO_MAP_SAT); break; case Mapstraction.HYBRID:map.setMapType(YAHOO_MAP_HYB); break; default:map.setMapType(YAHOO_MAP_REG);}break; case 'google':case 'openstreetmap':switch(type) { case Mapstraction.ROAD:map.setMapType(G_NORMAL_MAP); break; case Mapstraction.SATELLITE:map.setMapType(G_SATELLITE_MAP); break; case Mapstraction.HYBRID:map.setMapType(G_HYBRID_MAP); break; default:map.setMapType(G_NORMAL_MAP);}break; case 'microsoft':switch(type) { case Mapstraction.ROAD:map.SetMapStyle(Msn.VE.MapStyle.Road); break; case Mapstraction.SATELLITE:map.SetMapStyle(Msn.VE.MapStyle.Aerial); break; case Mapstraction.HYBRID:map.SetMapStyle(Msn.VE.MapStyle.Hybrid); break; default:map.SetMapStyle(Msn.VE.MapStyle.Road);}break; case 'multimap':maptypes = map.getAvailableMapTypes(); maptype = -1; for (var i = 0; i < maptypes.length; i++) { switch (maptypes[i]) { case MM_WORLD_MAP:if (type == Mapstraction.ROAD) { maptype = maptypes[i];}default_type = maptypes[i]; break; case MM_WORLD_AERIAL:if (type == Mapstraction.SATELLITE) { maptype = maptypes[i];}break; case MM_WORLD_HYBRID:if (type == Mapstraction.HYBRID) { maptype = maptypes[i];}break;}}if (maptype == -1) { maptype = default_type;}map.setMapType(maptype); break; case 'mapquest':switch (type) { case Mapstraction.ROAD:map.setMapType("map"); break; case Mapstraction.SATELLITE:map.setMapType("sat"); break; case Mapstraction.HYBRID:map.setMapType("hyb"); break;}break; default:if(this.debug)alert(this.api + ' not supported by Mapstraction.setMapType');}}Mapstraction.prototype.getMapType = function() { if(this.loaded[this.api] == false) { myself = this; return -1;}var map = this.maps[this.api]; var type; switch (this.api) { case 'yahoo':type = map.getCurrentMapType(); switch(type) { case YAHOO_MAP_REG:return Mapstraction.ROAD; break; case YAHOO_MAP_SAT:return Mapstraction.SATELLITE; break; case YAHOO_MAP_HYB:return Mapstraction.HYBRID; break; default:return null;}break; case 'google':case 'openstreetmap':type = map.getCurrentMapType(); switch(type) { case G_NORMAL_MAP:return Mapstraction.ROAD; break; case G_SATELLITE_MAP:return Mapstraction.SATELLITE; break; case G_HYBRID_MAP:return Mapstraction.HYBRID; break; default:return null;}break; case 'microsoft':type = map.GetMapStyle(); switch(type) { case Msn.VE.MapStyle.Road:return Mapstraction.ROAD; break; case Msn.VE.MapStyle.Aerial:return Mapstraction.SATELLITE; break; case Msn.VE.MapStyle.Hybrid:return Mapstraction.HYBRID; break; default:return null;}break; case 'multimap':maptypes = map.getAvailableMapTypes(); type = map.getMapType(); switch(type) { case MM_WORLD_MAP:return Mapstraction.ROAD; break; case MM_WORLD_AERIAL:return Mapstraction.SATELLITE; break; case MM_WORLD_HYBRID:return Mapstraction.HYBRID; break; default:return null;}break; case 'mapquest':type = map.getMapType(); switch(type) { case "map":return Mapstraction.ROAD; break; case "sat":return Mapstraction.SATELLITE; break; case "hyb":return Mapstraction.HYBRID; break; default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -