CN110365738A - Localization method, device and storage medium based on Hybird framework - Google Patents
Localization method, device and storage medium based on Hybird framework Download PDFInfo
- Publication number
- CN110365738A CN110365738A CN201910469671.5A CN201910469671A CN110365738A CN 110365738 A CN110365738 A CN 110365738A CN 201910469671 A CN201910469671 A CN 201910469671A CN 110365738 A CN110365738 A CN 110365738A
- Authority
- CN
- China
- Prior art keywords
- map
- plug
- unit
- finder
- cordova
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/29—Geographical information databases
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Remote Sensing (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The present invention relates to technical field of data processing, a kind of localization method based on Hybird framework, device and storage medium are proposed, method therein includes: to check whether be equipped with map plug-in object on browser window object after starting finder;When being equipped with map plug-in object on browser window object, the current location in the map plug-in unit is called to obtain program by Javascript;Program is obtained based on the current location, executes caller;After caller is finished, program is executed by the current location in the java file under cordova invocation map plug-in unit;Whether application where checking the finder includes positioning permission;When application has positioning permission, routine call map developing instrument is executed by current location, current position coordinates are returned to by map developing instrument.The present invention calls primary SDK localization method, can reach high accuracy positioning by the Cordvoa frame in Hybird, can be applied to APP and the high-precisions business scenario such as navigate, registers.
Description
Technical field
The present invention relates to user positioning technology field more particularly to a kind of localization methods based on Hybird framework, device
And computer readable storage medium.
Background technique
Mobile phone positioning refers to through specific location technology the location information (longitude and latitude for obtaining cell phone or terminal user
Spend coordinate), it is marked on the electronic map by the technology or service of the position of positioning object.There are two types of location technologies, and one is bases
In the positioning of GPS, one is the positioning of the base station based on mobile operation network.Based on the positioning method of GPS using on mobile phone
GPS positioning module sends positioning backstage for the position signal of oneself to realize mobile phone positioning.Base station location is then to utilize base
It stands to the measuring and calculating distance of the distance of mobile phone and determines mobile phone location.The latter, which does not need mobile phone, has GPS positioning ability, but smart
Degree depends greatly on the distribution of base station and the size of coverage area, and error can be more than one kilometer.The former positioning accuracy is higher.
In addition there are by Wifi a small range positioned in the way of.
Currently, on Hybird framework locating cellphone method, there are mainly three types of scheme, the first scheme is to pass through
Cordova-plugin-googlemaps plug-in unit, using the Android's and iOSSDK for calling primary Google based on Cordova
Scheme, although program positioning accuracy is high, for the country, access Google address is limited, for ordinary user
There are certain difficulties.Second scheme is the cordova-plugin-geolocation plug-in unit using Cordova official, this
Kind plug-in unit is there are certain compatibility issue and plug-in unit itself is based on GPS positioning, and error range is larger, for high-precision fixed
The scene of position is not applicable.The third scheme is the HTML5 positioning method based on browser positioning, the shortcomings that this method or essence
Spend low, error is larger, is not suitable for the scene of high accuracy positioning.
Summary of the invention
The present invention provides a kind of localization method based on Hybird framework, electronic device and computer readable storage medium,
Main purpose is to pass through the cordova.exec method call of Cordova exposure based on the Cordvoa frame in Hybird
Primary SDK localization method, to be finally reached the purpose that Native is interacted with Javascript.
To achieve the above object, the present invention provides a kind of localization method based on Hybird framework, is applied to electronic device,
The described method includes:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova in the java file under the map plug-in unit
Current location executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, passes through institute
It states map developing instrument and returns to current position coordinates.
Preferably, described after the step of whether being equipped with map plug-in object on the inspection browser window object
Method further include:
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program, and obtains callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
Preferably, the map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window,
The map plug-in object is obtained by window.AMapPlugin on Javascript, and to described
Method under window.AMapPlugin is called.
Preferably, the finder is mounted on HybirdAPP, and the cordova-plugin-amap is to meet
The plug-in unit of cordova specification;
The cordova-plugin-amap is mounted on the HybirdAPP by the installation order that cordova is executed
On.
Preferably, after the step of whether application includes positioning permission where the inspection finder, the side
Method further include:
When the application where the finder does not have positioning permission, feedback error information or positioning permission is carried out
Authorized application, and after the authorized application, whether application where the current finder of rechecking includes positioning permission.
Preferably, the map plug-in unit includes getcurrentposition method, the side startUpdatePosition
Method, readUpdatePosition method, stopUpdatePosition method, showMap method, hideMap method and
TraceMap method.
In addition, to achieve the above object, the present invention also provides a kind of electronic device, the electronic device include: memory and
Processor includes the finder based on Hybird framework in the memory, the finder based on Hybird framework
Following steps are realized when being executed by the processor:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova in the java file under the map plug-in unit
Current location executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, passes through institute
It states map developing instrument and returns to current position coordinates.
Preferably, described after the step of whether being equipped with map plug-in object on the inspection browser window object
Method further include:
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program, and obtains callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
Preferably, the map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window,
The map plug-in object is obtained by window.AMapPlugin on Javascript, and to described
Method under window.AMapPlugin is called.
To achieve the above object, the present invention also provides a kind of computer readable storage medium, the computer-readable storages
It include the finder based on Hybird framework in medium, the finder based on Hybird framework is executed by processor
When, realize the arbitrary steps of the localization method as described above based on Hybird framework.
Localization method based on Hybird framework, electronic device and computer readable storage medium proposed by the present invention, base
Cordvoa frame in Hybird, the primary SDK localization method of cordova.exec method call exposed by Cordova,
To achieve the purpose that Native is interacted with Javascript, high accuracy positioning plug-in unit under domestic cordova frame can make up for it
The defect of vacancy, positioning accuracy are high, can be applied to APP and the high-precisions business scenario such as navigate, register.
Detailed description of the invention
Fig. 1 is the application environment schematic diagram of localization method of the specific embodiment of the invention based on Hybird framework;
Fig. 2 is the module diagram of the finder preferred embodiment based on Hybird framework in Fig. 1;
Fig. 3 is the flow chart one of localization method of the specific embodiment of the invention based on Hybird framework;
Fig. 4 is the flowchart 2 of localization method of the specific embodiment of the invention based on Hybird framework.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The present invention provides a kind of localization method based on Hybird framework, is applied to a kind of electronic device 1.Institute referring to Fig.1
Show, for the present invention is based on the application environment schematic diagrames of the localization method preferred embodiment of Hybird framework.
In the present embodiment, electronic device 1 can be server, smart phone, tablet computer, portable computer, on table
Type computer etc. has the terminal device of calculation function.
The electronic device 1 includes: processor 12, memory 11, network interface 14 and communication bus 15.
Memory 11 includes the readable storage medium storing program for executing of at least one type.The readable storage medium storing program for executing of at least one type
It can be the non-volatile memory medium of such as flash memory, hard disk, multimedia card, card-type memory 11.In some embodiments, described
Readable storage medium storing program for executing can be the internal storage unit of the electronic device 1, such as the hard disk of the electronic device 1.At other
In embodiment, the readable storage medium storing program for executing is also possible to the external memory 11 of the electronic device 1, such as the electronic device
The plug-in type hard disk being equipped on 1, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital,
SD) block, flash card (Flash Card) etc..
In the present embodiment, the readable storage medium storing program for executing of the memory 11 is installed on the electronic device commonly used in storage
1 finder 10 etc. based on Hybird framework.The memory 11 can be also used for temporarily storing exported or
The data that will be exported.
Processor 12 can be in some embodiments a central processing unit (Central Processing Unit,
CPU), microprocessor or other data processing chips, program code or processing data for being stored in run memory 11, example
Such as execute the finder 10 based on Hybird framework.
Network interface 14 optionally may include standard wireline interface and wireless interface (such as WI-FI interface), be commonly used in
Communication connection is established between the electronic device 1 and other electronic equipments.
Communication bus 15 is for realizing the connection communication between these components.
Fig. 1 illustrates only the electronic device 1 with component 11-15, it should be understood that being not required for implementing all show
Component out, the implementation that can be substituted is more or less component.
Optionally, which can also include user interface, and user interface may include input unit such as keyboard
(Keyboard), speech input device such as microphone (microphone) etc. has the equipment of speech identifying function, voice defeated
Device such as sound equipment, earphone etc. out, optionally user interface can also include standard wireline interface and wireless interface.
Optionally, which can also include display, and display is referred to as display screen or display unit.
It can be light-emitting diode display, liquid crystal display, touch-control liquid crystal display and Organic Light Emitting Diode in some embodiments
(Organic Light-Emitting Diode, OLED) touches device etc..Display is used to show and handle in the electronic apparatus 1
Information and for showing visual user interface.
Optionally, which further includes touch sensor.It is touched provided by the touch sensor for user
The region for touching operation is known as touch area.In addition, touch sensor described here can be resistive touch sensor, capacitor
Formula touch sensor etc..Moreover, the touch sensor not only includes the touch sensor of contact, proximity may also comprise
Touch sensor etc..In addition, the touch sensor can be single sensor, or such as multiple biographies of array arrangement
Sensor.
In addition, the area of the display of the electronic device 1 can be identical as the area of the touch sensor, it can also not
Together.Optionally, display and touch sensor stacking are arranged, to form touch display screen.The device is based on touching aobvious
Display screen detects the touch control operation of user's triggering.
Optionally, which can also include radio frequency (Radio Frequency, RF) circuit, sensor, audio
Circuit etc., details are not described herein.
In Installation practice shown in Fig. 1, as may include in a kind of memory 11 of computer storage medium behaviour
Make system and the finder 10 based on Hybird framework;Processor 12 execute memory 11 in store based on Hybird
Following steps are realized when the finder 10 of framework:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova in the java file under the map plug-in unit
Current location executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, passes through institute
It states map developing instrument and returns to current position coordinates.
Specifically, browser window object, which is seen, can select AMapPlugin for window subject map plug-in unit, when
Front position, which obtains program, can select AMapPlugin.getcurrentposition () method, and caller can be
JSBridge cordova.exe (), current location, which executes program, can select GET_LOCATION_ACTION, map exploitation
Tool can be Amap SDK etc., and corresponding above steps can be described as:
Check whether AMapPlugin object is installed on browser window object after starting finder;
When being equipped with AMapPlugin object on the browser window, called by Javascript described in
AMapPlugin.getcurrentposition () method in AMapPlugin;
Based on the AMapPlugin.getcurrentposition () method, JSBridge cordova.exe is executed
();
After the JSBridge cordova.exe () is finished, called under AMapPlugin by cordova
GET_LOCATION_ACTION in AMapPlugin.java file;
Whether application where checking current finder includes positioning permission;
When the application has positioning permission, by GET_LOCATION_ACTION method call Amap SDK, pass through
The Amap SDK returns to current position coordinates.
Wherein, after detecting finder starting, finder operation, and by judging whether have in Javascript
Map plug-in object checks whether be equipped with map plug-in object on browser object, if so, then invocation map plug-in object
On current location obtain program, and obtain callback data, otherwise return to error message or prompt installation plug-in unit.
In addition, cordova as a kind of open source projects, is that (PhoneGap is one using HTML, CSS from PhoneGap
With the technology of Javascript, the quick development platform of the mobile cross-platform mobile applications of creation) in the core code extracted out,
It is to drive the core engine of PhoneGap, and JSBridge therein refers mainly to the bridge before JS (Javascript) and Native
Beam, and actually JSBridge be JS and Native before a kind of communication mode so that Native only pass through one it is fixed
Bridge object reference JS, JS also only pass through fixed bridge object reference Native.
SDK (Software Development Kit, Software Development Kit) is typically all that some software engineers are
The set of developing instrument when specific software package, software frame, hardware platform, operating system etc. establish application software, GET_
LOCATION_ACTION is that the movement of user current location acquisition methods executes order.
Wherein, map plug-in unit AMapPlugin is pair that cordova-plugin-amap is exposed on browser window
As.The object and right can be got by window.AMapPlugin on Javascript
Method under window.AMapPlugin is called, for example is called under window.AMapPlugin
AMapPlugin.getCurrentPosition()。
And finder is then located on HybirdAPP, cordova-plugin-amap is to meet inserting for cordova specification
Part executes installation order by cordova and is mounted on HybirdAPP.
Amap SDK encapsulates primary SDK by Amap, is integrated with Amap and often uses basic interface, belongs to mobile terminal
The primary map of version can be by GPS positioning for JS map, base station location, and three kinds of station-keeping modes of mixed positioning are
User provides high-precision positioning service, and developer can be arranged geography fence, realize that high-precision pushes away by obtaining user location
It send, by user distribution reasonable Arrangement resource, realizes maximizing the benefits.
Preferably, the step of whether being equipped with map plug-in unit map plug-in object on the inspection browser window object it
Afterwards, the method also includes:
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program, and obtains callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
Preferably, the map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window,
The map plug-in object is obtained by window.AMapPlugin on Javascript, and to described
Method under window.AMapPlugin is called.
Preferably, the finder is mounted on HybirdAPP, and the cordova-plugin-amap is to meet
The plug-in unit of cordova specification;
The cordova-plugin-amap is mounted on the HybirdAPP by the installation order that cordova is executed
On.
Preferably, after the step of whether application where checking the finder includes positioning permission, the method is also
Include:
When the application where the finder does not have positioning permission, feedback error information or positioning permission is carried out
Authorized application, and after the authorized application, whether application where the current finder of rechecking includes positioning permission.
Preferably, the map plug-in unit includes getcurrentposition method, the side startUpdatePosition
Method, readUpdatePosition method, stopUpdatePosition method, showMap method, hideMap method and
TraceMap method.
The electronic device 1 that above-described embodiment proposes passes through Cordova exposure based on the Cordvoa frame in Hybird
The primary SDK localization method of cordova.exec method call, to achieve the purpose that Native is interacted with Javascript, to make up
The vacancy of high accuracy positioning plug-in unit under domestic Cordova frame realizes and is based on GPS positioning, base station location, mixed positioning one
Positioning service, positioning accuracy is high, and the high-precisions business scenario such as can navigate and register using APP.
In other embodiments, the finder 10 based on Hybird framework can also be divided into one or more mould
Block, one or more module are stored in memory 11, and are executed by processor 12, to complete the present invention.Institute of the present invention
The module of title is the series of computation machine program instruction section for referring to complete specific function.Referring to shown in Fig. 2, to be based in Fig. 1
The Program modual graph of 10 preferred embodiment of finder of Hybird framework.The finder 10 based on Hybird framework can
To be divided into: inspection unit 101, map plug-in unit call unit 102, JSBridge execution unit 103, position acquisition unit
104, authority acquiring unit 105, position determination unit 106.The functions or operations step that the module 101-106 is realized with
Similar above, and will not be described here in detail, illustratively, such as wherein:
Inspection unit 101, for checking that whether being equipped with map on browser window object inserts after starting finder
Part object;
Map plug-in unit call unit 102, for passing through when being equipped with map plug-in object on the browser window
Javascript calls the current location in the map plug-in unit to obtain program;
JSBridge execution unit 103 executes caller for obtaining program based on the current location;
Position acquisition unit 104, for passing through cordova invocation map plug-in unit after the caller is finished
Under java file in current location execute program;
Authority acquiring unit 105, for application where checking the finder whether comprising positioning permission;
Position determination unit 106, for executing program technic by current location when the application has positioning permission
Invocation map developing instrument returns to current position coordinates by the map developing instrument.
In addition, the present invention also provides a kind of localization methods based on Hybird framework.It is jointly shown referring to Fig. 3 and Fig. 4, be
Two kinds of flow charts of the localization method based on Hybird framework of the specific embodiment of the invention.This method can be held by a device
Row, which can be by software and or hardware realization.
In the present embodiment, the localization method method based on Hybird framework includes: step S110- step S160, specifically
It is as follows:
Step S110: check whether map plug-in object is installed on browser window object after starting finder.
Wherein, after detecting finder starting, finder operation, and by judging whether have in Javascript
Map plug-in object checks whether be equipped with map plug-in object on browser window object, if so, then invocation map plug-in unit
Current location on object obtains program, and obtains callback data, otherwise returns to error message.
Step S120: when being equipped with map plug-in object on the browser window, institute is called by Javascript
The current location stated in map plug-in unit obtains program.
Wherein, browser window object, which is seen, can select AMapPlugin for window subject map plug-in unit, currently
Position acquisition program can select AMapPlugin.getcurrentposition () method, AmapPlugin object or map
Plug-in object refers to that Amap plug-in unit, AMapPlugin.getcurrentposition () refer in Amap plug-in unit
The program technic of one acquisition user current location.
Step S130: program is obtained based on the current location, executes caller.
Wherein, the determination of user location can't be realized by only obtaining program by current location, also need to pass through at this time
A current location under caller invocation map plug-in unit executes program, executes program execution position by current location and obtains
Movement.
In addition, browser window object, which is seen, can select AMapPlugin for window subject map plug-in unit, currently
Position acquisition program can select AMapPlugin.getcurrentposition () method, and caller can be
JSBridge cordova.exe (), current location, which executes program, can select GET_LOCATION_ACTION, map exploitation
Tool can be Amap SDK etc., and cordova is that (PhoneGap is one and adopts from PhoneGap as a kind of open source projects
With the technology of HTML, CSS and Javascript, the quick development platform of the mobile cross-platform mobile applications of creation) in extraction
Core code, be drive PhoneGap core engine, and JSBridge therein refer mainly to JS (Javascript) and
Bridge before Native, and actually JSBridge be JS and Native before a kind of communication mode so that Native only
Also only pass through fixed bridge object reference Native by fixed bridge object reference a JS, JS.
S140: after the caller is finished, by the java file under cordova invocation map plug-in unit
Current location executes program.
S150: whether application where checking the finder includes positioning permission.
Wherein, SDK (Software Development Kit, Software Development Kit) is typically all some soft projects
Teacher is the set of developing instrument when specific software package, software frame, hardware platform, operating system etc. establish application software,
GET_LOCATION_ACTION is that the movement of user current location acquisition methods executes order.
Wherein, map plug-in unit is the object that cordova-plugin-amap is exposed on browser window.?
Javascript is upper can to get the object by window.AMapPlugin, and under window.AMapPlugin
Method is called, for example calls the AMapPlugin.getCurrentPosition () under window.AMapPlugin,
In, window.AMapPlugin is program in machine code, and main function is to obtain or call out map under browser window to insert
Part AMapPlugin.
And finder is then located on HybirdAPP, cordova-plugin-amap is the ground for meeting cordova specification
Figure plug-in unit can be executed corresponding installation order by cordova and is mounted on HybirdAPP, cordova-plugin-amap
It is the map plug-in unit on open source projects cordova, some primary SDK can be called by the plug-in unit.
Step S160: when the application has positioning permission, routine call map is executed by current location and develops work
Tool returns to current position coordinates by the map developing instrument.
Wherein, HybirdAPP is the ionic frame based on Cordova, and ionic is one and is absorbed in WEB exploitation skill
Art is similar to a Development Framework of cell phone platform native applications based on HTML5 creation, is bundled with AngularJS and Sass.
The purpose of this frame is to develop mobile phone application from the angle of web, and the compiling platform based on PhoneGap may be implemented to be compiled into
The application program of each platform.
It should be noted that needing to be added dynamic when calling primary function for Android 6.0 and the above version and weighing
Limit needs to carry out authorized application when application does not include positioning permission.
Wherein, Amap SDK encapsulates primary SDK by Amap, is integrated with Amap and often uses basic interface, belongs to shifting
The dynamic primary map of terminal version can pass through GPS positioning, base station location, three kinds of mixed positioning positioning for JS map
Mode provides high-precision positioning service for user, and developer can be arranged geography fence, realize high by obtaining user location
Precision push realizes maximizing the benefits by user distribution reasonable Arrangement resource.
As shown in connection with fig. 4, the present invention is based on localization method of the Hybird framework under scene of registering to specifically include following step
It is rapid:
Step 1: finder is pre-installed on Hybird APP, is clicked the button of registering on Hybird APP, is passed through
Button of registering starts finder.
Step 2: judge on browser window object with the presence or absence of AmapPlugin object.
Step 3: if performing the next step, otherwise prompting there are AmapPlugin object on browser window object
Plug-in unit is installed, user is reminded to carry out plug-in unit installation.
Wherein, in single positioning, first determine whether there is AMapPlugin object in Javascript, if so, then
The getCurrentPosition method on AmapPlugin object is called, and obtains callback data;If no
AMapPlugin object, then pop up error message on interface.Wherein, shell by alert (" data "+
JSON.stringify (data)), the callback data of getCurrentPosition return is popped up in Javascript on boundary
On face, for debugging, while also it is defeated that character string combinations can be converted by data object by JSON.stringify (data)
Out.
Step 4: it when being equipped with AMapPlugin object on the browser window, is called by Javascript
AMapPlugin.getcurrentposition () method in the AMapPlugin.
Step 5: being based on the AMapPlugin.getcurrentposition () method, executes JSBridge
cordova.exe()。
Wherein, two objects of cordova and cordova/exec are introduced first in Javascript, are then defined
The type of AMapPlugin is Function, increases getCurrentPosition newly to AmapPlugin, and receive
Two parameters of successCallback and errorCallback.Cordova/exec method is called in function, passes through exec
(successCallback, errorCallback, " AMapPlugin ", " getCurrentPosition ", []) is incoming to be needed
Pass to the parameter of cordvoa;AMapPlugin object is registered, in cordova so that Android and iOS are called.
Step 6: after the JSBridge cordova.exe () is finished, AMapPlugin is called by cordova
Under AMapPlugin.java file in GET_LOCATION_ACTION.
Wherein, by taking Android SDK is called and obtained current location as an example, AMapPlugin.java file is called by cordova
In GET_LOCATION_ACTION, obtain contextual information, re-define parameters needed for some singles position,
SetOnceLocation is true, and the mode etc. of positioning is arranged in setLocationMode, finally by
CurLocationClient.startLocation () starts to position.
Step 7: whether application where judging current finder includes positioning permission.
Step 8: if application is performed the next step, otherwise authorized comprising positioning permission where current finder
Application, until obtaining positioning permission.
Step 9: when the application has positioning permission, pass through GET_LOCATION_ACTION method call Amap
SDK comprising GPS can also be used in the multiple positioning modes such as GPS, base station, WIFI, bluetooth, sensor, base station is tied with WIFI phase
Mixed positioning mode of conjunction etc..
Step 10: current location high-precision coordinate is returned to by the Amap SDK.
It should be noted that getcurrentposition is only a method in AMapPlugin, further, it is also possible to
Called by Javascript startUpdatePosition method in the AMapPlugin,
ReadUpdatePosition method, stopUpdatePosition method, showMap method, hideMap method,
TraceMap method etc., implementation procedure can refer to above step.
Using the above-mentioned localization method based on Hybird framework, one kind has been capable of providing based on high-precision on Hybird framework
Localization method is spent, to compensate for the vacancy of high accuracy positioning plug-in unit under domestic Cordova frame, realizes and is based on GPS positioning, base station
Positioning, the positioning service of mixed positioning one, positioning accuracy are high, can be using APP navigation and the high-precisions business scenario such as register.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, the computer readable storage medium
In include the finder based on Hybird framework, the realization when finder based on Hybird framework is executed by processor
Following operation:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova in the java file under the map plug-in unit
Current location executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, passes through institute
It states map developing instrument and returns to current position coordinates.
Preferably, described after the step of whether being equipped with map plug-in object on the inspection browser window object
Method further include:
When being equipped with map plug-in object on the browser window object, the map is called by Javascript
Current location in plug-in unit obtains program, and obtains callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
Preferably, the map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window,
The AMapPlugin object is obtained by window.AMapPlugin on Javascript, and to described
Method under window.AMapPlugin is called.
Preferably, the finder is mounted on HybirdAPP, and the cordova-plugin-amap is to meet
The plug-in unit of cordova specification;
The cordova-plugin-amap is mounted on the HybirdAPP by the installation order that cordova is executed
On.
Preferably, after the step of whether application includes positioning permission where the inspection finder, the side
Method further include:
When the application where the finder does not have positioning permission, feedback error information or positioning permission is carried out
Authorized application, and after the authorized application, whether application where the current finder of rechecking includes positioning permission.
Preferably, the map plug-in unit includes getcurrentposition method, the side startUpdatePosition
Method, readUpdatePosition method, stopUpdatePosition method, showMap method, hideMap method and
TraceMap method.
The specific embodiment of the computer readable storage medium of the present invention and the above-mentioned positioning side based on Hybird framework
Method, the specific embodiment of electronic device are roughly the same, and details are not described herein.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that the process, device, article or the method that include a series of elements not only include those elements, and
And further include other elements that are not explicitly listed, or further include for this process, device, article or method institute it is intrinsic
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do
There is also other identical elements in the process, device of element, article or method.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.Pass through above embodiment party
The description of formula, it is required general that those skilled in the art can be understood that above-described embodiment method can add by software
The mode of hardware platform is realized, naturally it is also possible to which by hardware, but in many cases, the former is more preferably embodiment.It is based on
Such understanding, substantially the part that contributes to existing technology can be with software product in other words for technical solution of the present invention
Form embody, which is stored in a storage medium (such as ROM/RAM, magnetic disk, light as described above
Disk) in, including some instructions use is so that a terminal device (can be mobile phone, computer, server or the network equipment
Deng) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair
Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills
Art field, is included within the scope of the present invention.
Claims (10)
1. a kind of localization method based on Hybird framework is applied to electronic device, which is characterized in that the described method includes:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map plug-in unit is called by Javascript
In current location obtain program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova current in the java file under the map plug-in unit
Position executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, by describedly
Figure developing instrument returns to current position coordinates.
2. the localization method according to claim 1 based on Hybird framework, which is characterized in that the inspection browser window
After the step of whether being equipped with map plug-in object on mouth object, the method also includes:
When being equipped with map plug-in object on the browser window object, the map plug-in unit is called by Javascript
In current location obtain program, and obtain callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
3. the localization method according to claim 1 based on Hybird framework, which is characterized in that
The map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window, on Javascript
Obtain the map plug-in object by window.AMapPlugin, and to the method under the window.AMapPlugin into
Row calls.
4. the localization method according to claim 3 based on Hybird framework, which is characterized in that
The finder is mounted on HybirdAPP, and the cordova-plugin-amap is to meet what cordova was standardized
Plug-in unit;
The cordova-plugin-amap is mounted on the HybirdAPP by the installation order that cordova is executed.
5. the localization method according to claim 1 based on Hybird framework, which is characterized in that described to check the positioning
After the step of whether application where program includes positioning permission, the method also includes:
When the application where the finder does not have positioning permission, feedback error information or the authorization for carrying out positioning permission
Application, and after the authorized application, whether application where the current finder of rechecking includes positioning permission.
6. the localization method according to claim 1 based on Hybird framework, which is characterized in that
The map plug-in unit include getcurrentposition method, startUpdatePosition method,
ReadUpdatePosition method, stopUpdatePosition method, showMap method, hideMap method and
TraceMap method.
7. a kind of electronic device, which is characterized in that the electronic device includes: memory and processor, includes in the memory
Based on the finder of Hybird framework, realized such as when the finder based on Hybird framework is executed by the processor
Lower step:
Check whether map plug-in object is installed on browser window object after starting finder;
When being equipped with map plug-in object on the browser window object, the map plug-in unit is called by Javascript
In current location obtain program;
Program is obtained based on the current location, executes caller;
After the caller is finished, called by cordova current in the java file under the map plug-in unit
Position executes program;
Whether application where checking the finder includes positioning permission;
When the application has positioning permission, routine call map developing instrument is executed by current location, by describedly
Figure developing instrument returns to current position coordinates map plug-in object map plug-in object.
8. electronic device according to claim 7, which is characterized in that whether installed on the inspection browser window object
After having the step of map plug-in object, the method also includes:
When being equipped with map plug-in object on the browser window object, the map plug-in unit is called by Javascript
In current location obtain program, and obtain callback data;
Otherwise, then plug-in unit is installed in feedback error information or prompt.
9. electronic device according to claim 7, which is characterized in that
The map plug-in unit is that cordova-plugin-amap is exposed to the object on browser window, on Javascript
Obtain the map plug-in object by window.AMapPlugin, and to the method under the window.AMapPlugin into
Row calls.
10. a kind of computer readable storage medium, which is characterized in that include being based in the computer readable storage medium
The finder of Hybird framework when the finder based on Hybird framework is executed by processor, is realized as right is wanted
The step of localization method based on Hybird framework described in asking any one of 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910469671.5A CN110365738B (en) | 2019-05-31 | 2019-05-31 | Positioning method, device and storage medium based on Hybird architecture |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910469671.5A CN110365738B (en) | 2019-05-31 | 2019-05-31 | Positioning method, device and storage medium based on Hybird architecture |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110365738A true CN110365738A (en) | 2019-10-22 |
CN110365738B CN110365738B (en) | 2022-04-12 |
Family
ID=68215031
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910469671.5A Active CN110365738B (en) | 2019-05-31 | 2019-05-31 | Positioning method, device and storage medium based on Hybird architecture |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110365738B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114356452A (en) * | 2021-12-31 | 2022-04-15 | 必要鸿源(北京)科技有限公司 | Method and device for acquiring positioning result information, electronic equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102830997A (en) * | 2012-08-17 | 2012-12-19 | 北京金山软件有限公司 | Method, device and equipment for controlling plug-in installation |
US20160092179A1 (en) * | 2014-09-26 | 2016-03-31 | Oracle International Corporation | High performant ios template based application build system |
US20160283448A1 (en) * | 2015-03-23 | 2016-09-29 | International Business Machines Corporation | Accessing location-based information on a mobile device |
CN106528184A (en) * | 2016-12-29 | 2017-03-22 | 山东浪潮商用系统有限公司 | App development method based on cordova platform |
US9678726B1 (en) * | 2015-03-27 | 2017-06-13 | Amazon Technologies, Inc. | Automatic generation of plugins for development tools |
CN106912104A (en) * | 2017-02-28 | 2017-06-30 | 和创(北京)科技股份有限公司 | Localization method and terminal device |
CN107479906A (en) * | 2017-09-28 | 2017-12-15 | 电子科技大学 | cross-platform online education mobile terminal based on Cordova |
-
2019
- 2019-05-31 CN CN201910469671.5A patent/CN110365738B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102830997A (en) * | 2012-08-17 | 2012-12-19 | 北京金山软件有限公司 | Method, device and equipment for controlling plug-in installation |
US20160092179A1 (en) * | 2014-09-26 | 2016-03-31 | Oracle International Corporation | High performant ios template based application build system |
US20160283448A1 (en) * | 2015-03-23 | 2016-09-29 | International Business Machines Corporation | Accessing location-based information on a mobile device |
US9678726B1 (en) * | 2015-03-27 | 2017-06-13 | Amazon Technologies, Inc. | Automatic generation of plugins for development tools |
CN106528184A (en) * | 2016-12-29 | 2017-03-22 | 山东浪潮商用系统有限公司 | App development method based on cordova platform |
CN106912104A (en) * | 2017-02-28 | 2017-06-30 | 和创(北京)科技股份有限公司 | Localization method and terminal device |
CN107479906A (en) * | 2017-09-28 | 2017-12-15 | 电子科技大学 | cross-platform online education mobile terminal based on Cordova |
Non-Patent Citations (2)
Title |
---|
怯肇乾: "Cordova-APP软件及其插件开发", 《电脑编程技巧与维护》 * |
花开花又谢: "使用plugman开发cordova高德地图定位插件", 《CSDN HTTPS://BLOG.CSDN.NET/U010730897/ARTICLE/DETAILS/54969638》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114356452A (en) * | 2021-12-31 | 2022-04-15 | 必要鸿源(北京)科技有限公司 | Method and device for acquiring positioning result information, electronic equipment and storage medium |
CN114356452B (en) * | 2021-12-31 | 2024-03-19 | 必要鸿源(北京)科技有限公司 | Method and device for acquiring positioning result information, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110365738B (en) | 2022-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107038112B (en) | Application interface debugging method and device | |
EP3133845B1 (en) | Method and apparatus for pushing and displaying message | |
CN108345531B (en) | Test method, device and system | |
CN105191360B (en) | Based on the method, system and mobile device close to fence | |
US9495543B2 (en) | Method and apparatus providing privacy benchmarking for mobile application development | |
CN111881019B (en) | User interface testing method and device | |
CN103996205B (en) | The method of a kind of electronic equipment and operation electronic equipment | |
CN104268472B (en) | Reduction is by the method and apparatus of third party's dynamic base Modification growth function address | |
CN103777967A (en) | Page returning method and page generating method and device | |
CN104580499A (en) | Method and device for accurately labeling positions | |
WO2018149137A1 (en) | Wireless fidelity (wi-fi) connection method and related product | |
CN107957956A (en) | Test method, device and the readable storage medium storing program for executing of software differences coverage rate | |
CN105723337A (en) | Incrementally compiling software artifacts from interactive development environment | |
CN105740145B (en) | The method and device of element in orient control | |
CN107818046A (en) | The A/B method of testings and device of the application program page | |
WO2023045628A1 (en) | Analog card activation method and apparatus, and terminal and storage medium | |
CN107797996B (en) | Entry translation method and device | |
CN105072105A (en) | Message marking processing method and processing system based on intelligent terminal | |
CN109211250B (en) | Method and device for automatically converting electronic map coordinates of mobile terminal | |
CN104991857B (en) | Trace debug method and device | |
CN105572704A (en) | Method for supporting Beidou module under Android platform | |
CN110365738A (en) | Localization method, device and storage medium based on Hybird framework | |
CN107402756B (en) | Method, device and terminal for drawing page | |
CN108932264A (en) | The determination method, apparatus and storage medium of navigation problem | |
CN111124627B (en) | Method and device for determining call initiator of application program, terminal and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20210129 Address after: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.) Applicant after: Shenzhen saiante Technology Service Co.,Ltd. Address before: 1-34 / F, Qianhai free trade building, 3048 Xinghai Avenue, Mawan, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong 518000 Applicant before: Ping An International Smart City Technology Co.,Ltd. |
|
TA01 | Transfer of patent application right | ||
GR01 | Patent grant | ||
GR01 | Patent grant |