OpenLayers-based Javascript class definition for map Encapsulation

Source: Internet
Author: User
Tags prototype definition

Zookeeper

OpenLayers-based Javascript class definition for map Encapsulation

MapCwgisClass. js

// Web map encapsulation class // MapCwgisClass class definition // vp: hsg, myk // create date: 2013-07-26 // class prototype definition var Person = function () {this. m_Name = "good";} Person. prototype = {m_Name: '', getName: function () {return this. m_Name ;}// class prototype defines var MapCwgisClass = function () {// OpenLayers Environment Parameter OpenLayers. IMAGE_RELOAD_ATTEMPTS = 5; OpenLayers. DOTS_PER_INCH = 25.4/0.28; OpenLayers. INCHES_PER_UNIT ["km"] = OpenLayers. INCHES_PER_UNIT ["km"]; OpenLayers. INCHES_PER_UNIT ["meters"] = OpenLayers. INCHES_PER_UNIT ["m"]; OpenLayers. INCHES_PER_UNIT ["Miles"] = OpenLayers. INCHES_PER_UNIT ["mi"]; OpenLayers. INCHES_PER_UNIT ["Inch"] = OpenLayers. INCHES_PER_UNIT ["ft"]; this. defaultFormat = 'image/png '; // this. map = null;} MapCwgisClass. prototype = {// property wms_url: null, wms_url_getFeature: null, map_divid: null, map: null, currentClientPoint: null, currentClientMapPo Int: null, m_CurrentTool: null, ProxyHost: null, defaultFormat: null, defaprojecprojection: null, defaultBounds: null, vlayer_drawFeature: null, layer_Highlight: null, LayerList: null, // custom wms layer attribute map_Raster: null, map_Cadastra: null, // layer name layer_DOM: "RFS_DOM", // DOM layer name; layer_XZQ: "RFS_XZQ ", // Administrative Region layer name layer_DX: "RFS_MZDW", // other geographic layer name layer_ZD: "RFS_CBD_ZD", // consortium name // new layer layer_ZD_LS: "RFS_CBD_LS ", // plot calendar Layer Name // method // initialization Map Method init: function () {// OpenLayers. ProxyHost = 'geoserverproxy. aspx? URL = '; OpenLayers. proxyHost = this. proxyHost; // default parameter this. defaultProjection = "EPSG: 2358"; this. defaultBounds = new OpenLayers. bounds (34602000.15, 3318000.3500000006, 34609999.65, 3326999.8500000006); var bounds = this. defaultBounds; // option var options = {controls: [], // Add new OpenLayers in the [] field if the edit box is added. control. editingToolbar (vlayer) maxExtent: bounds, maxResolution: 35.154296875, projection: this.de FaultProjection, units: 'M', allOverlays: false // true indicates that overlapping layers are allowed}; // map object initialization this. map = new OpenLayers. map (this. map_divid, options); map = this. map; // assign mapWrap = this to the global variable map; // assign var t_LLPoint = new OpenLayers to the global variable. lonLat (0, 0); // this. setCenterPoint (t_LLPoint, 3); // zoom in to the specified range map // this. map. zoomToExtent (bounds); //}, setCenterPoint: function (openLayerLonLatPoint, Level) {if (this. map! = Null) {this. map. setCenter (openLayerLonLatPoint, Level) ;}, // create a wms layer createLayerWms: function (p_mapName, p_wms_url, p_layers) {var t_mapLayer = new OpenLayers. layer. WMS (p_mapName, p_wms_url, {layers: p_layers, styles: '', tiled: true, srs: defaultProjection, format: defaultFormat}, {singleTile: true, ratio: 1 }); return t_mapLayer;}, // create a Vector layer createLayerVector: function (p_LayerName) {var T_layer_vector = new OpenLayers. layer. vector (p_LayerName); return t_layer_vector;}, // create a query layer createLayerQuery: function (p_QueryLayerName) {var t_querylayerName = 'query layername '; if (p_QueryLayerName! = Null & p_QueryLayerName! = "") {T_querylayerName = p_QueryLayerName;} var t_styleMap = new OpenLayers. styleMap ({"default": {strokeColor: "# FF0000", strokeOpacity: 1, fillColor: "# 6699ff", fillOpacity: 0.2}); var t_layer_Query = new OpenLayers. layer. vector (t_querylayerName, t_styleMap); return t_layer_Query;}, // Add layer addLayer: function (pLayer) {if (this. map! = Null) {this. map. addLayers ([pLayer]) ;}}, // Add layer set addLayers: function (pLayers) {if (this. map! = Null) {this. map. addLayers ([pLayers]) ;}}, // Add control of common Map System Tools // Add system command control OK addSystemCommands: function () {// this. map. addControl (new OpenLayers. control. layerSwitcher (); // Add the scale line var t_scaleline = new OpenLayers. control. scaleLine ({topOutUnits: "km", topInUnits: "meters", bottomOutUnits: "Miles", bottomInUnits: "inches"}); t_scaleline.setMap (this. map); this. map. addControl (t_scaleline); // Add scale var t_scale = new Ope NLayers. control. scale (); t_scale.setMap (this. map); this. map. addControl (t_scale); // Add the mouse point var t_mouseposition = new OpenLayers. control. mousePosition (); t_mouseposition.setMap (this. map); this. map. addControl (t_mouseposition); // Add the eagleeye chart var t_ovmap = new OpenLayers. control. LTOverviewMap (); t_ovmap.setMap (this. map); this. map. addControl (t_ovmap); // Add the Zomm animation var t_zommAnimation = new OpenLayers. control. LTZommAnim Ation (); t_zommAnimation.setMap (this. map); this. map. addControl (t_zommAnimation); // Add a translation zoom bar var t_panZoomBar = new OpenLayers. control. panZoomBar ({position: new OpenLayers. pixel (2, 15)}); t_panZoomBar.setMap (this. map); this. map. addControl (t_panZoomBar); // Add var t_navigation = new OpenLayers. control. navigation (); t_navigation.setMap (this. map); this. map. addControl (t_navigation);}, addSystemCommands _ Normal: function () {// Add the mouse point var t_mouseposition = new OpenLayers. control. mousePosition (); t_mouseposition.setMap (this. map); this. map. addControl (t_mouseposition); // Add the Zomm animation var t_zommAnimation = new OpenLayers. control. using ommanimation (); t_zommAnimation.setMap (this. map); this. map. addControl (t_zommAnimation);}, // Add measurement Command Control addMeasureCommands: function () {// measurement control operation var sketchSymbolizers = {"Point": {gr AphicName: "cross", graphicHeight: 8, graphicWidth: 8, fillColor: "# FF0000", fillOpacity: 1, strokeWidth: 0, }, "Line": {strokeWidth: 1.5, strokeOpacity: 1, strokeColor: "# 0000FF"}, "Polygon": {strokeWidth: 1.5, strokeOpacity: 1, strokeColor: "# 0000FF", fillColor: "# ccccff ", fillOpacity: 0.3 }}; var style = new OpenLayers. style (); style. addRules ([new OpenLayers. rule ({symbolizer: sketchSymboli Zers})]); var styleMap = new OpenLayers. styleMap ({"default": style}); var renderer = OpenLayers. util. getParameters (window. location. href ). renderer; renderer = (renderer )? [Renderer]: OpenLayers. layer. vector. prototype. renderers; var options = {persist: true, handlerOptions: {style: "default", layerOptions: {renderers: renderer, styleMap: styleMap }}; // line, surface Measurement measureControls = {line: new OpenLayers. control. measure (OpenLayers. handler. path, options), polygon: new OpenLayers. control. measure (OpenLayers. handler. polygon, options)}; var control; for (var key in measureControls) {control = measureControls [key]; control. events. on ({"measure": handleMeasure, // "measurepartial": handleMeasurePartial // when the measurement distance is added to a point}); this. map. addControl (control); this. layerList. add (control) ;}}, // command point, line, and surface addDrawFeatureCommands: function () {this. vlayer_drawFeature = new OpenLayers. layer. vector (); this. map. addLayer (vlayer_drawFeature); drawControls = {point: new OpenLayers. control. drawFeature (this. vlayer_drawFeature, OpenLayers. handler. point), line: new OpenLayers. control. drawFeature (this. vlayer_drawFeature, OpenLayers. handler. path), polygon: new OpenLayers. control. drawFeature (this. vlayer_drawFeature, OpenLayers. handler. polygon)}; for (var key in drawControls) {this. map. addControl (drawControls [key]); this. layerList. add (drawControls [key]) ;}}, // add panel addPanel: function () {var panel = new OpenLayers. control. panel (); this. map. addControls (panel); addPanelControls = {zoomBox: new OpenLayers. control. zoomBox ()}; for (var key in addPanelControls) {this. map. addControl (addPanelControls [key]) ;}}, // zoomToFeatures: function (features) {if (features = null | features = 'undefined') return; var left = 0; var top = 0; var right = 0; var bottom = 0; // for (I = 0; I
 
  
Top | top = 0) top = geoBound. top; if (geoBound. right> right | right = 0) right = geoBound. right; if (geoBound. bottom
  
   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.