The content of the invention
It is an object of the invention to provide a kind of Internet map application development platform based on open source projects, so as to solve
Foregoing problems present in prior art.
To achieve these goals, the technical solution adopted by the present invention is as follows:
A kind of Internet map application development platform based on open source projects, including:
Map develops class libraries, and based on open source projects OpenLayers exploitations, the bottom based on its source code uses face
Encapsulate upper class and method to the programming idea of object, write using JavaScript language, for rendering in webpage front-end and
Displaying map;
Reference documents, written in code and specifications of annotation according to specified in the map develops class libraries, use JSDoc from source
Mass production in code, for explaining and illustrating that the map develops class, attribute and method in class libraries;
Example page, develops class libraries and makes using the packed map, can online editing debugging, cover describedly
All of class and method in figure exploitation class libraries, are carried out with reference to using for developer in exploitation.
Preferably, the map exploitation class libraries is used to render and show map in webpage front-end, specifically includes:Stacking chart
Layer, covering is added on map;It is the figure layer and covering binding event;Control is shown in the map page;By interface
Measurement distance, measurement area;Spatially shape, key search POI;Carry out spatial analysis.
Preferably, the figure layer includes VectorLayer and grid tile figure layer;The covering includes point, line, surface and letter
Breath window;The event includes clicking on and mouse action;The control include right button menu, engineer's scale, hawkeye, city switching,
Navigation, plotting and positioning;The spatial analysis includes Spatial Overlap, conversion and calculates.
Preferably, the spatial analysis is implemented using following steps:
Step one, the map elements object that the map is developed in class libraries is converted to the GeoJosn objects of standard;
Step 2, spatial analysis behaviour is carried out using the analysis method of Turf.js to the standard GeoJson objects in step one
Make, analysis result is GeoJson objects;
Step 3, the object in map exploitation class libraries is converted to by GeoJson analysis results described in step 2, and
It is shown in map.
Preferably, the reference documents, using JSDoc from source code Mass production, specially:It is automatic based on what is increased income
Change document structure tree instrument JSDoc, the document template in its source code is modified according to the aesthetic property displaying requirement of document, to institute
State map exploitation class libraries source code and be standardized annotation, Mass production.
Preferably, the reference documents, for explaining and illustrating that the map develops class, attribute and method in class libraries, tool
Body is that the list of all classes is listed in the page of the reference documents, and the attribute, method and method parameter to each class enter
Row is described in detail and described, using class name and method name as the link for redirecting access.
Preferably, the example page, including map, covering, messagewindow, Map OCX, mouse action, event are tied up
The example of fixed, retrieval, positioning, map overlay, right button menu and spatial analysis.
Preferably, the example page, including 33 classes, 88 examples.
Preferably, the example page, source code editor is created using Codemirror technologies in the page, while
Displaying code operational effect.
The beneficial effects of the invention are as follows:Internet map application and development based on open source projects provided in an embodiment of the present invention
Platform, using the Programming thought of object-oriented, common internet works software development language is converted into by GIS professional languages,
Based on the Openlayers front-end map rendering engines increased income, 33 map foundation class and 25 spatial analysis interfaces are encapsulated,
The interfaces such as class, the method for encapsulation are easily understood, and OGC standard maps data, Map Services are supported, with front end spatial analysis work(
Energy.Solve non-majored GIS education developer exploitation Internet map application when learning cost is high, be unable to flexible access standard map
The problems such as service and map datum.
Specific embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, below in conjunction with accompanying drawing, the present invention is entered
Row is further described.It should be appreciated that specific embodiment described herein is only used to explain the present invention, it is not used to
Limit the present invention.
As shown in figure 1, a kind of Internet map application development platform based on open source projects is the embodiment of the invention provides,
Including:
Map develops class libraries, and based on open source projects OpenLayers exploitations, the bottom based on its source code uses face
Encapsulate upper class and method to the programming idea of object, write using JavaScript language, for rendering in webpage front-end and
Displaying map;
Reference documents, written in code and specifications of annotation according to specified in the map develops class libraries, use JSDoc from source
Mass production in code, for explaining and illustrating that the map develops class, attribute and method in class libraries;
Example page, develops class libraries and makes using the packed map, can online editing debugging, cover describedly
All of class and method in figure exploitation class libraries, are carried out with reference to using for developer in exploitation.
In actual mechanical process, map is developed class libraries and is developed based on open source projects OpenLayers, is made with its source code
Based on bottom, use object-oriented programming idea encapsulate upper class and method.For example, to ol.Map classes as internal object
Encapsulation BigMap.Map classes;Ol.Feature and ol.Overlay unifications are encapsulated as BigMap.Overlay classes, only in class libraries
Distinguish inside;The complicated object properties relation such as ol.map.layer.source is reduced to BigMap.Map.Layer, so that
Developer is simplified to the understanding of map object and is used.
Meanwhile, the strict difinition specification of written in code and annotation in the embodiment of the present invention, so as to improve source code
It is readable and maintainable.
Wherein, the development process of map exploitation class libraries can specifically be adopted and implemented with the following method:
1st, using the attribute and method of prototype object definition classes, for example, BigMap.Map.prototype.addLa
Yer defines the method that Map objects add figure layer.
2nd, succession and the dependence of class are defined using open source projects Google Closure Library, in each class
The class stated the affiliated NameSpace of class and relied on is needed before definition, for example, adding sentence before the definition of Marker classes
goog.provide('BigMap.Marker');goog.require('ol.Feature');State that such belongs to BigMap lives
The name space simultaneously depends on ol.Feature classes.
3rd, code annotation uses YUIDoc specifications of annotation, is what content for what is write in one code block of statement.Example
As following comment statement illustrates that the code block defines the setAnimation methods of Marker classes, for setting Marker's
Animation effect.'@param ' are a labels, and the parameter for stating method is the meaning of what type and parameter.Herein,
What the animation types that the parameter of setAnimation one String type of needs indicates Marker and carries out are.
After the completion of class libraries is write, front end webpage is called for convenience, the use of Google Closure Library is source generation
Code builds and relies on and compress packing, operates as follows:
1st, the dependence that Python scripts build class libraries is write
Closure-library/closure/bin/build/depswriter.py-root_wit h_prefix="
BigMap/BigMap../../../BigMap/BigMap " -- output_file=" build/BigMap.deps.js ".
2nd, Python scripts compression source code file is write
Closure-library/closure/bin/build/closurebuilder.py--roo t=closure
- library/--root=BigMap/BigMap--root=ol/--root=ol.ext/
-- namespace=" BigMap.Map " -- output_mode=compiled
-- compiler_jar=compiler.jar>build/BigMap.min.js.
The BigMap.min.js for ultimately generating as map kits, by putting it under network path in webpage
Quote to develop web map application.
In the embodiment of the present invention, the map exploitation class libraries is used to render and show map in webpage front-end, specifically includes:
It is superimposed figure layer, covering is added on map;It is the figure layer and covering binding event;Control is shown in the map page;It is logical
Cross interface measurement distance, measurement area;Spatially shape, key search POI;Carry out spatial analysis.
Wherein, the figure layer includes VectorLayer and grid tile figure layer;The covering includes point, line, surface and information
Window;The event includes clicking on and mouse action;The control includes that right button menu, engineer's scale, hawkeye, city switch, lead
Boat, plotting and positioning;The spatial analysis includes Spatial Overlap, conversion and calculates.
In the embodiment of the present invention, because the GIS exploitation class libraries using Openlayers specialties is very detailed by its object discrimination ground
Carefully, by taking VectorLayer as an example, VectorLayer objects include Source and Style objects, and Source objects include Feature
Object, and Feature objects receive coordinate data.In the present invention is implemented, the direct of Layer is set to by by Feature
Subobject, simplifies the understanding of developer.Give up Style objects simultaneously, pattern directly is set using the set methods of Feature.Institute
To use platform development provided in an embodiment of the present invention interface out to allow exploitation with minimal amount of and most plain structural relation
Person is readily appreciated that and uses.
In a preferred embodiment of the invention, the spatial analysis can be implemented using following steps:
Step one, the map elements object that the map is developed in class libraries is converted to the GeoJosn objects of standard;
Step 2, spatial analysis behaviour is carried out using the analysis method of Turf.js to the standard GeoJson objects in step one
Make, analysis result is GeoJson objects;
Step 3, the object in map exploitation class libraries is converted to by GeoJson analysis results described in step 2, and
It is shown in map.
Map provided in an embodiment of the present invention develops class libraries, with spatial analysis functions, based on the Turf.js bottoms increased income
It is packaged.Turf.js supports the analysis to single map elements, and the GeoJson data of standard are analyzed and are exported
The object of GeoJson forms.Map elements object in class libraries is converted to the GeoJosn forms pair of standard first in the present invention
As, spatial operation then is carried out using the analysis method of Turf, GeoJson objects are finally converted into the object in class libraries, and
It is shown in map.
Spatial analysis functions implement step, are herein carried out specifically by taking buffer finish blasting function Buffer as an example
Bright, its code can be as follows:
That is, the realization of buffer finish blasting function can be divided into following 4 steps:
1. platform overlay objects are converted into turf storehouses polygon objects, the method for using is turf.polygon
(geometryPoints);
2. buffer finish blasting operation is performed, turf storehouses turf.buffer () method is called;
3. turf analysis results json is converted into platform Polygon objects;
4. the Polygon after changing directly can be added on map by map.addOverlay () method.
In one embodiment of the invention, the reference documents, using JSDoc from source code Mass production, specifically
Can be:Based on the document automation Core Generator JSDoc for increasing income, to the document template in its source code according to document aesthetic property
Displaying requirement is modified, and annotation, Mass production are standardized to map exploitation class libraries source code.
Written in code and specifications of annotation according to specified in exploitation class libraries process, use document automation instrument JSDoc
Class library reference document can in bulk be generated.Jsdoc_toolkit-2.4.0 is used in the present invention, MyEclipse's
Run under Java context.As shown in Figure 2.
In fig. 2, the template file under templates files therein is changed come the reference documents page required for reaching
Face pattern requirement.Wherein .tmpl files are the templates of each several part in webpage, and default.css is the stylesheet files of webpage,
Default.js is the script for controlling page operation, and Index.html is the homepage of whole reference documents.
After the completion of template modification, the build.properties configuration files in modification source code have specified template position
And the outgoing position of document.
Then build.xml files are run in Ant Built modes in MyEclipse, ultimately generates web page files hair
Cloth for developer to browsing in website.
Wherein, the reference documents, for explaining and illustrating that the map develops class, attribute and method in class libraries, specifically
For, the list of all classes is listed in the page of the reference documents, the attribute, method and method parameter to each class are carried out
Describe in detail and describe, using class name and method name as the link for redirecting access.
In the embodiment of the present invention, the example page, including map, covering, messagewindow, Map OCX, mouse behaviour
The example of work, event binding, retrieval, positioning, map overlay, right button menu and spatial analysis.
Wherein, the demonstration effect of buffer finish blasting is carried out reference can be made to shown in Fig. 3 and 4.
In the embodiment of the present invention, the example page, including 33 classes, 88 examples.The map is covered to develop in class libraries
All of class and method, use so that developer refers to when map application is developed.
In the embodiment of the present invention, the example page creates source code editor using Codemirror technologies in the page
Device, while showing code operational effect.
Specifically, all 33 map classes provided in an embodiment of the present invention, attribute and method that each class is necessary to, class
It is listed as follows:
88 online examples, classify and are listed as follows:
So, the Internet map application development platform based on open source projects provided in an embodiment of the present invention has following excellent
Point:
1st, the class of API, method, interface are easily understood, and save the learning cost of developer.
2nd, with the ability for accessing standard map data and service, data display mode is more flexible.
3rd, with the function of front end spatial analysis, the exploitation of application backstage and related resource are reduced.
4th, code sample can online editing debugging, facilitate developer quickly to use.
By using above-mentioned technical proposal disclosed by the invention, following beneficial effect has been obtained:The embodiment of the present invention is carried
The Internet map application development platform based on open source projects for supplying, using the Programming thought of object-oriented, by GIS specialties
Language is converted into common internet works software development language, based on the Openlayers front-end map rendering engines increased income, encapsulation
The interfaces such as 33 map foundation class and 25 spatial analysis interfaces, class, the method for encapsulation are easily understood, and support OGC study plots
Diagram data, Map Services, with front end spatial analysis functions.Solving non-majored GIS education developer exploitation Internet map should
Used time learning cost is high, the problems such as be unable to the service of flexible access standard map and map datum.
Each embodiment in this specification is described by the way of progressive, what each embodiment was stressed be with
The difference of other embodiment, between each embodiment identical similar part mutually referring to.
Those skilled in the art should be understood that the sequential of the method and step that above-described embodiment is provided can be entered according to actual conditions
Row accommodation, is concurrently carried out also dependent on actual conditions.
All or part of step in the method that above-described embodiment is related to can be instructed by program correlation hardware come
Complete, described program can be stored in the storage medium that computer equipment can read, for performing the various embodiments described above side
All or part of step described in method.The computer equipment, for example:Personal computer, server, the network equipment, intelligent sliding
Dynamic terminal, intelligent home device, wearable intelligent equipment, vehicle intelligent equipment etc.;Described storage medium, for example:RAM、
ROM, magnetic disc, tape, CD, flash memory, USB flash disk, mobile hard disk, storage card, memory stick, webserver storage, network cloud storage
Deng.
Finally, in addition it is also necessary to explanation, herein, such as first and second or the like relational terms be used merely to by
One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation
Between there is any this actual relation or order.And, term " including ", "comprising" or its any other variant meaning
Covering including for nonexcludability, so that process, method, commodity or equipment including a series of key elements not only include that
A little key elements, but also other key elements including being not expressly set out, or also include for this process, method, commodity or
The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", does not arrange
Except also there is other identical element in the process including the key element, method, commodity or equipment.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should
Depending on protection scope of the present invention.