GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Showing posts with label Google API. Show all posts
Showing posts with label Google API. Show all posts

Saturday, March 12, 2011

Google - Map API

Here's a simple example for Google Maps generation as png file:
http://maps.google.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false
The basic url is: http://maps.google.com/maps/api/staticmap?parameters

The parameters explained:
1. center - the place you search. if there's a spaci, fill it with plus sign.
    like for new york -> new+york
2. zoom - zoom level
3. size - width x height
4. sensor - false or true
5. maptype - roadmap, terrain, satellite and hibrid







/**
 * Here's an example on how to use it using javascript
 */

<h1>Google Maps API</h1>
<img src="" id="img"/>

<script>
function renderMap(data, el){
 var center = data.center;
 var zoom = data.zoom;
 var width = data.width;
 var height = data.height;
 var sensor = false;

 var url = "http://maps.google.com/maps/api/staticmap?center="+ center +"&zoom="+ zoom +"&size="+ width +"x"+ height +"&sensor="+sensor;
 el.setAttribute('src',url);                
}

var data = {};
 data.center = "Jakarta";
 data.zoom = 15;
 data.width = 200;
 data.height = 200;

var img = document.getElementsByTagName('img')[0];
renderMap(data,img);

</script>
Share/Bookmark

Friday, March 11, 2011

Google - Pie Chart API

Here's a simple demo on how to render a chart image from Google API:
https://chart.googleapis.com/chart?chs=550x100&chd=t:50,140,30&cht=p3&chl=Hello|World|For

chs = chart size in width x height
chd = chart data
cht = chart type - p, p3, v, lc, lc:nda, bvs
chl = chart label
chco = color - separated comma or bar
chtt = title
chts = color and font of title - ff00ff,15
chdl = legend - medan|jogja|malang
chma = margin - left, right,top,bottom|width,height
chf = backgrouning - bg,s,faffaa
chf = background gradient - c,lg,sudut,leftColor,0,rightColor,1

For more information, see here Google Char API



Share/Bookmark