Created
November 20, 2008 22:02
-
-
Save Oshuma/27233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Insert a map, based on IP GeoLocation. | |
| CmdUtils.CreateCommand({ | |
| name: "map-me", | |
| description: "Dynamically insert a map, based on IP GeoLocation.", | |
| _getMapUrl: function() { | |
| var loc = CmdUtils.getGeoLocation(); | |
| var mapUrl = "http://maps.google.com/staticmap?"; | |
| var params = { | |
| center: loc.lat + "," + loc.long, | |
| size: "500x400", | |
| zoom: 14, | |
| key: "ABQIAAAAGZ11mh1LzgQ8-8LRW3wEShQeSuJunOpTb3RsLsk00-MAdzxmXhQoiCd940lo0KlfQM5PeNYEPLW-3w" | |
| }; | |
| return mapUrl + jQuery.param( params ); | |
| }, | |
| preview: function( pblock ) { | |
| var msg = "Inserts a map of your current location: <br />"; | |
| msg += "<img src='%s' />".replace( /%s/, this._getMapUrl() ); | |
| }, | |
| execute: function() { | |
| CmdUtils.getImageSnapshot( this._getMapUrl(), function(imgData) { | |
| CmdUtils.setSelection( "<img src='" + imgData + "' />"); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment