-
Notifications
You must be signed in to change notification settings - Fork 123
/
gmap.js
47 lines (46 loc) · 1.63 KB
/
gmap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// {{{ INFO
var INFO =xml`
<plugin name="gmap.js" version="0.1"
summary="Get google maps URL of current machine location."
href="http://github.com/vimpr/vimperator-plugins/blob/master/gmap.js"
xmlns="http://vimperator.org/namespaces/liberator">
<author email="[email protected]">Mitsugu Oyama</author>
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
<project name="Vimperator" minVersion="2.3"/>
<p>
You can get Google Maps URL of current machine location by this plugin.
</p>
<item>
<tags>'GoogleMaps'</tags>
<spec>:gmap</spec>
<description>
<p>You can get Google Maps URL of current machine location by this plugin.</p>
<dl>
<dt>See.</dt>
<dd>
<p><link topic="http://mozilla.jp/firefox/features/geolocation/">http://mozilla.jp/firefox/features/geolocation/</link> (Japanese)</p>
<p><link topic="https://developer.mozilla.org/Ja/Using_geolocation">https://developer.mozilla.org/Ja/Using_geolocation</link> (Japanese)</p>
</dd>
</dl>
</description>
</item>
</plugin>`;
// }}}
(function(){
commands.addUserCommand(
['gmap'],
'Get Google Map URL of current location',
function(){
let strURL='http://maps.google.com/maps?ie=UTF8&q=';
let Cc=Components.classes;
let Ci=Components.interfaces;
let geolocation=Cc["@mozilla.org/geolocation;1"]
.getService(Ci.nsIDOMGeoGeolocation);
geolocation.getCurrentPosition(function(position){
let strL=position.coords.latitude+','+position.coords.longitude;
liberator.echo(strURL+strL);
util.copyToClipboard(strURL+strL,true);
});
}
);
})();