forked from geosolutions-it/MapStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Google.Shortener class
mstn edited this page Jul 16, 2012
·
12 revisions
Class: Google.Shortener
location: MSMUtil.js
requires: Ext Js
Access Google service to shorten urls. See also Google Documentation.
This component makes cross browser calls because it relies on an external rest service. The current implementation uses the http_proxy developed by GeoSolutions. Hence, you need to add Google url to proxy config file proxy.properties.
- Add www.googleapis.com to hostnameWhitelist,
- Add (.google.) (or another regexp) to reqtypeWhitelist.fdh,
- Redeploy http_proxy, if necessary.
var shortener = new Google.Shortener({
appid: /* PUT HERE YOUR GOOGLE API KEY */
}).failure(function(response){
/* CALLBACK METHOD IF SOMETHING WENT WRONG */
});
});
// async method to shorten urls
shortener.shorten(
/* YOUR VERY LONG URL */,
function(response){
/* response.id contains your short URL */
});