Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.1 Author Tutorial

11 bytes added, 22:43, 10 September 2008
Map Me! Location, Snapshots, and Inserting HTML
</pre>
There are three new things here: <code>CmdUtils.setSelection</code> to set HTML (yep, it can do that); the use of <code>CmdUtils.getGeoLocation()</code>; and using <code>CmdUtils.snapshotImagegetImageSnapshot()</code> to capture the bits for the image.
I find getting the location&mdash;as imprecise as IP-based location can be&mdash;useful for doing sensible defaults for location-based commands, like Yelp. <code>CmdUtils.getGeoLocation()</code> returns an object which has the following properties: city, state, country, lat, and long.
Why do we need to use <code>CmdUtils.snapshotImagegetImageSnapshot()</code>? Because the Google Maps API requires a key that is tied to a particular URL. If we naively inject the image tag into a random web page, the image won't load because the key doesn't match that random web page's URL. Thus, we use the <code>snapshotImage()</code> function to convert the image into a [http://en.wikipedia.org/wiki/Data:_URI_scheme data url].
There's also a <code>CmdUtils.snapshotWindowgetWindowSnapshot()</code> function, which allows you to get the image data for any tab/window. The function takes a window as the first paramater, and a callback for the second.
= Commands with Arguments =
1,007
edits

Navigation menu