Wednesday, March 28, 2012

Google Weather Map JavaScript

It's a example from Google Code Playground for Weather Map.
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps API Sample</title>
    <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAuPsJpk3MBtDpJ4G8cqBnjRRaGTYH6UMl8mADNa0YKuWNNa8VNxQCzVBXTx2DYyXGsTOxpWhvIG7Djw" type="text/javascript"></script>
    <script src="http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js"></script>
    <script type="text/javascript">

    var IMAGES = [ "sun", "rain", "snow", "storm" ];
    var ICONS = [];
    var map = null;
    var mgr = null;
    
    function setupMap() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(48.25, 11.00), 4);
        map.enableDoubleClickZoom();
        window.setTimeout(setupWeatherMarkers, 0);
      }
    }
    
    function getWeatherIcon() {
      var i = Math.floor(IMAGES.length*Math.random());
      if (!ICONS[i]) {
        var icon = new GIcon();
        icon.image = "http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/examples/images/"
            + IMAGES[i] + ".png";
        icon.iconAnchor = new GPoint(16, 16);
        icon.infoWindowAnchor = new GPoint(16, 0);
        icon.iconSize = new GSize(32, 32);
        icon.shadow = "http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/examples/images/"
            + IMAGES[i] + "-shadow.png";
        icon.shadowSize = new GSize(59, 32);
        ICONS[i] = icon;
      }
      return ICONS[i];
    }
    
    function getRandomPoint() {
      var lat = 48.25 + (Math.random() - 0.5)*14.5;
      var lng = 11.00 + (Math.random() - 0.5)*36.0;
      return new GLatLng(Math.round(lat*10)/10, Math.round(lng*10)/10);
    }
    
    function getWeatherMarkers(n) {
      var batch = [];
      for (var i = 0; i < n; ++i) {
        batch.push(new GMarker(getRandomPoint(), { icon: getWeatherIcon() }));
      }
      return batch;
    }
    
    function setupWeatherMarkers() {
      mgr = new MarkerManager(map);
      mgr.addMarkers(getWeatherMarkers(20), 3);
      mgr.addMarkers(getWeatherMarkers(200), 6);
      mgr.addMarkers(getWeatherMarkers(1000), 8);
      mgr.refresh();
    }

    </script>
  </head>
  <body onload="setupMap()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
    <div id="map" style="margin: 5px auto; width: 650px; height: 400px"></div>
    <div style="text-align: center; font-size: large;">
      Random Weather Map
    </div>
</body>
</html>

Tuesday, March 27, 2012

Javascript query Yahoo! Weather by zip

Javascript query Yahoo! Weather by zip We can use Javascrip get XML from "http://query.yahooapis.com/v1/public/yql/jonathan/weather?zip=94025", to query Yahoo! Weather by zip code. It's a example to query weather for zip code 94025, Menlo Park, CA.
Javascript query Yahoo! Weather by zip

<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Yahoo! Weather by zip</title>

<script>

function loadyahooweather()
{
 if (window.XMLHttpRequest)
 { // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
 } else {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 
 xmlhttp.open("GET","http://query.yahooapis.com/v1/public/yql/jonathan/weather?zip=94025",false);
 xmlhttp.send();
 xmlDoc=xmlhttp.responseXML; 
 
 //description=xmlDoc.getElementsByTagName("description");
 
 
 description0=(xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue);
 description1=(xmlDoc.getElementsByTagName("description")[1].childNodes[0].nodeValue);
 
 txt = "<p><b>" + description0 + "</b></p>";
 txt += "<p>" + description1 + "</p>";

 //txt = "<p>title: " + "</p>";
   
 document.getElementById("yahooweather").innerHTML=txt;
}
</script>
</head>
<body onload="loadyahooweather()">
<h1>Mobile-Web-App: Yahoo! Weather by zip</h1>
<div id='yahooweather'></div>

</body>
</html>

Monday, March 26, 2012

Parse XML using Javascript

Yahoo API provide some web service. For example, the following link return xml of some information of a place search by text of "New York".
http://query.yahooapis.com/v1/public/yql?q=select*from%20geo.places%20where%20text=%22New%20York%22&format=xml

We can use JavaScript to parse the xml to retrieve information; such as WOEID, placeTypeName, name and much more. The example display WOEID, placeTypeName, name of the first place in the returned list.

Parse XML using Javascript
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: XML Parse</title>

<script>

function loadwoeid()
{
 if (window.XMLHttpRequest)
 { // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
 } else {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 
 xmlhttp.open("GET","http://query.yahooapis.com/v1/public/yql?q=select*from%20geo.places%20where%20text=%22New%20York%22&format=xml",false);
 xmlhttp.send();
 xmlDoc=xmlhttp.responseXML; 
 
 place=xmlDoc.getElementsByTagName("place");
 firstplace = place[0];
 
 woeid=(firstplace.getElementsByTagName("woeid")[0].childNodes[0].nodeValue);
 placetypename=(firstplace.getElementsByTagName("placeTypeName")[0].childNodes[0].nodeValue);
 name=(firstplace.getElementsByTagName("name")[0].childNodes[0].nodeValue);
 
 txt = "<p>WOEID: " + woeid + "</p>" 
   + "<p>placeTypeName: " + placetypename + "</p>" 
   + "<p>name: "+ name +"</p>";
   
 document.getElementById("woeidtable").innerHTML=txt;
}
</script>
</head>
<body onload="loadwoeid()">
<h1>Mobile-Web-App: XML Parse</h1>
<div id='woeidtable'></div>

</body>
</html>

WebKit For Dummies


Get up to speed on the engine that powers Safari and Google Chrome
What do the web browsers on iPhone, iPad, Android, Blackberry, Kindle, and Nokia have in common with Google Chrome and Apple Safari? WebKit powers them all. This guide shows you how to create web sites and mobile web apps using WebKit. Learn to use all the developer tools, the latest web standards, and WebKit's unique styles and functions to create appealing, interactive sites for mobile and desktop display.
Explores how WebKit supports HTML5 and CSS3, providing a large toolkit for creating faster and better mobile web sites
  • Explains how to create web pages for both mobile and desktop display using WebKit
  • Covers acquiring and installing the developer tools, building web pages, debugging and deploying them, and taking advantage of WebKit functions to create faster, more appealing, and more interactive sites
With mobile devices proliferating at a rapid rate, there's never been a better time to learn all about the engine that powers the leading mobile browser. WebKit For Dummies teaches you to create web pages that make the most of everything WebKit has to offer.

Saturday, March 24, 2012

Simple example of Raphaël JavaScript library


Simple example of Raphaël JavaScript library
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Raphaël</title>

<script src="http://raphaeljs.com/raphael.js"></script>
<script>
var paper_w = 500;
var paper_h = 300;
window.onload = function () {
 var paper = Raphael("RaphaelPaper", paper_w, paper_h);
 paper.rect(0, 0, paper_w, paper_h, 20).attr({fill: "#333"});
 };
</script>

</head>
<body>
<h1>Mobile-Web-App: Raphaël</h1>
<div id="RaphaelPaper"/>

</body>
</html>
Raphaël is a small JavaScript library that should simplify your work with vector graphics on the web.

Thursday, March 22, 2012

Raphaël—JavaScript Library



Raphaël—JavaScript LibraryRaphaël is a small JavaScript library that should simplify your work with vector graphics on the web. If you want to create your own specific chart or image crop and rotate widget, for example, you can achieve it simply and easily with this library.

 Raphaël ['ræfeɪəl] uses the SVG W3C Recommendation and VML as a base for creating graphics. This means every graphical object you create is also a DOM object, so you can attach JavaScript event handlers or modify them later. Raphaël’s goal is to provide an adapter that will make drawing vector art compatible cross-browser and easy.

Raphaël currently supports Firefox 3.0+, Safari 3.0+, Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+.

 Web Site: http://raphaeljs.com/


Inkscape - An Open Source SVG graphics editor


Inkscape

Inkscape is an Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format.

Inkscape supports many advanced SVG features (markers, clones, alpha blending, etc.) and great care is taken in designing a streamlined interface. It is very easy to edit nodes, perform complex path operations, trace bitmaps and much more. Also aim to maintain a thriving user and developer community by using open, community-oriented development.

Web Site: http://inkscape.org/