Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Created November 20, 2008 22:02
Show Gist options
  • Select an option

  • Save Oshuma/27233 to your computer and use it in GitHub Desktop.

Select an option

Save Oshuma/27233 to your computer and use it in GitHub Desktop.
// 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