Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

Thursday, May 10, 2007

Sun JavaFX -Is this Ajax for Mobile?

So is this Ajax by Sun for Mobile? - this was what I said when I firt heard about JavaFX Mobile yesterday.

Sun Microsystems has announced JavaFX Script, a new family of Java for consumer rich media products like desktop web browser, TV, BluRay, automobile and mobile devices. The first product release is JavaFX Mobile.

According to Jeffrey Hammond, senior analyst at Forrester Research, this is more like JavaScript than Java, and could be an alternative to AJAX and also vies with Microsoft's Silverlight and Adobe's Apollo.

Anything ends with X sounds like a phony buzzword but this actually does sound interesting.

Tuesday, October 17, 2006

Using Google Maps API - Part.4: Info Window

Let's add more functions on the SFO map example.

Opening a Info Window

To create a basic baloon-like floating "info window", call the openInfoWindow(htmlElement) method, passing it a location and a DOM element as an argument to create a text node.

map.openInfoWindow(new GLatLng(37.622934, -122.392159),
                   document.createTextNode("SFO"));

or, use similar method openInfoWindowHtml(htmlString) which takes an HTML string as its argument rather than a DOM element.

map.openInfoWindowHtml(
 new GLatLng(37.622934, -122.392159), "SFO");

Opening a Info Window on Click

Simply calling these methods above just display the info windows upon loading the map. If you want the info window opened by clicking a marker, you need to use event listeners. The static method, GEvent.addListener takes a marker as the 1st argument, the event as the 2nd argument, and a function as the 3rd argument. The events provided by GMap2 Class include; click, infowindowopen and infowindowclose. To open a info window on click, write:

GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml("SFO<br/>CA 94128");
    });

Finally, to give the event to the custom icon previously made, create a new function to combine both displaying the icon and call the click event. The function createMarker takes four arguments, latitude, longitude, icon image URL, and description (html).

In addition to the GIcon properties previously set, define infoWindowAnchor and infoShadowAnchor as well.
var desc_sfo ="SFO - San Francisco Intl Airport<br/>CA 94128";
var marker_sfo = createMarker(37.622934, -122.392159, "icons/sfo.png", desc_sfo);
map.addOverlay(marker_sfo);

function createMarker(lat, lng, ico, html) {
 var point = new GLatLng(lat, lng);
 
 if (ico!=null) {
  var icon = new GIcon();
  icon.image = ico;
  icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
  icon.iconSize = new GSize(26, 44);
  icon.shadowSize = new GSize(50, 44);
  icon.iconAnchor = new GPoint(13, 44);
  icon.infoWindowAnchor = new GPoint(9, 2);
  icon.infoShadowAnchor = new GPoint(18, 25);
 }
 var marker = new GMarker(point, icon);
 GEvent.addListener(marker, 'click', function() {
  marker.openInfoWindowHtml(html);
  });
  return marker;
}

See also: Google Maps API Version 2 Reference

Monday, October 16, 2006

Using Google Maps API - Part.3: Create a Custom Icon

Let's continue on the quick guide of using Google Map API.

Using Custom Icons

The hardest part is creating graphics for your marker image and its shadow with Photoshop or something. The icons should be cretaed in 24-bit png format. For this example, I just tweaked the default icon (the color changed to blue, made it bigger, and typed "SFO" in it!) and used default shadow.

To replace the generic icon to your custom icon, add this code in the last script, before the line that begins with var marker = ...

var icon = new GIcon();
icon.image = "icons/sfo.png";
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(26, 44);
icon.shadowSize = new GSize(50, 44);
icon.iconAnchor = new GPoint(13, 44);

First, create a new icon instance (line 1).
Next two lines indicate icon/shadow image source path or URL. (I use default shadow image on Google server).
Next two specifies the image dimention in pixels.
iconAnchor point of the icon is the "pointy" tip where also its shadow image originates. In this case, the anchor point is 13 pixels over and 44 pixels down from the top-left corner of the SFO icon, and this is defined by iconAnchor (line 6).

Location of the marker is defined by GMarker, just as you see in the last example, except, this time you need to add the 2nd paramter to include the custom icon. Finally, call addOverlay() method to dispaly thr marker icon.

var marker = new GMarker(new GLatLng(37.622934, -122.392159), icon);
map.addOverlay(marker);

Next: Opening an Info Window

Thursday, October 12, 2006

Using Google Maps API - Basic Map Part.2 (Source Code)

The entire XHTML code (so far) looks like this:

<!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">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&v=2&key=YOUR_KEY"
      type="text/javascript"></script>

 <style type="text/css">
  body { font:12px Arial,Verdana,Helvetica,sans-serif;}
  #mapSFO {height: 300px; width: 350px;}
 </style>
  </head>
  <body>
 <!-- No JavaScript Message -->
   <noscript>
 <div class="noscript">
 <b>JavaScript must be enabled in order for you to use Google Maps.</b> <br/><br/>
      It seems JavaScript is either disabled or not supported by your browser. 
      To view Google Maps, please enable JavaScript by changing your browser options, and then 
      try again.
  </div>
    </noscript>
 
 <!-- Map Placeholder -->
 <div id="mapSFO"></div>
 
 <script type="text/javascript">
    //<![CDATA[
 
 var map = new GMap2(document.getElementById("mapSFO"));
 map.setCenter(new GLatLng(37.632934, -122.392159), 12);
 map.addControl(new GLargeMapControl());
 map.addControl(new GMapTypeControl());
 map.addControl(new GScaleControl());
 
 var marker = new GMarker(new GLatLng(37.622934, -122.392159));
 map.addOverlay(marker);
    </script>
  </body>
</html>

See Screenshot of the sample map.

Using Google Maps API - Basic Map Part.1

Here's a quick start guide of using Google Map API.

Before Started

  1. Sign up for the Google Maps API
  2. Copy the generated key
  3. Prepare to write a standards-compliant XHTML page with an appropriateDOCTYPE.

Get Started

Let's create a map indicating San Francisco International Airport (SFO).
First, include Google Maps JavaScript code source and your CSS in <head> section of HTML.

<script src="http://maps.google.com/maps?file=api&v=2&key=COPY_THE_KEY"
      type="text/javascript"></script>

<style type="text/css">
#mapSFO {height: 300px; width: 350px;}
</style>

Next, in <body>, create a placeholder of a map within a <div> with the map ID ("mapSFO").

Then creates a JavaScript GMap2 object to display a map. This GMap2 class represents a single map on the page. The center location of the map is defined in the next line, by latitude and longitude. The second parameter indicates the zoom level. 0 is most zoomed out and 17 is most detailed. (You can find any Latitude and longitude you want from geocoder.us)

<div id="mapSFO"></div>

<script type="text/javascript">
  //<![CDATA[ 
  var map = new GMap2(document.getElementById("mapSFO"));
  map.setCenter(new GLatLng(37.632934, -122.392159), 12);
</script>

View in browser. Now the map of SFO area is displayed.

Adding Controls

Optionally, you can add controls to the map with the addControl method.

  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.addControl(new GScaleControl());

See how the controls are added:

Also try; GSmallMapControl to see how it looks like!

Display a Marker

Displaying map markers is defined by GMarker. This uses the default red Google Maps icon unless specified. In this example, I use GLatLang method to define the location of SFO, since I've set the center of the map slightly off in the beginning. You can use getCenter() method to display a marker at center.
Finally, call addOverlay() method to dispaly thr marker icon.

  var marker = new GMarker(new GLatLng(37.622934, -122.392159));
  map.addOverlay(marker);

This is how it looks like in browser:

See the entire XHTML

OK. I will post the rest later when I have time.
(Next: Using Custom Icons, and Opening an Info Window)

Friday, October 06, 2006

Mobile 2.0 - RSS Feeds for Mobile

Nokia has announced the launch of WidSets is a mobile widget platform available for Java MIDP 2.0 phones and is manufacturer and browser independent (that works non-Nokia phones too). Like widgets on a computer, you can access to information from RSS feeds (news, blogs, flickr, etc). This is like for the mobile what Netvibes is for the browser. Cool.

O'Reilly Reader: Mobile 2.0 Nokia Launches WidSets

Saturday, July 15, 2006

YouOS - Web2.0 Online Platform

YouOS is an Ajax-based experimental "Web operating system" creates by guys at MIT. It is a window-based operating system with GUI that runs on browser so you can access your desktop from any computer anywhere. YouOS tracks a user's state across user sessions, so after you log off, you can log on from anywhere and your desktop and applications will be in the same state where you left them.

Amazingly, there are already nearly 200 applications you can install on YouOS account - rich text editor, email client, chat, RSS reader, also a couple of different web browsers! It's funny that the OS runs on browser and has its owen web browser. The screenshot show my other blog site displayed on YouBrowser. I dunno if it is really useful to view web within web though.

Saturday, July 01, 2006

Ajax Software - Free Adobe and Microsoft alternatives?

More and more online Ajax applications are coming. Online word processor, spreadsheet, and now, an image editor. This screenshot is taken from Snipshot where you can edit your images uploaded or imported from web such as flickr. (I used their sample photo to demo.) This online application allows you to edit images with basic tools like crop, rotate, resize, basic image adjustments.

List of other online "Office" appz:

Friday, June 16, 2006

Social Shopping List

Stylehive

It seems like an another big wave of Internet trend has been around (but hope this is not like the late-90s dot-com crap), the social-networking sites have been massive success (though I hate MySpace), "tagging" has been everywhere, and I started hearing news about new startups all the time.

Today, I've read about this "a collaborative shopping community" called Stylehive, whose office is located here in San Francisco. Though this site has so much more to be improved, the idea and look-and-feel of the site are something I can relate.

Browsing the tags like manolo makes me want them really want them. Bad for me, but this fits perfectly as we live in the material world.

(This blog entry was originally written on June 16 for my other blog and copied it on Blogger on Sept.27)

Wednesday, May 03, 2006

Yahoo! Tech

Yahoo! has launched a new tech products site, called Yahoo! Tech. This site is just like CNet but this utilizes fancy Web2.0 technologies like Flash and Ajax-enabled dynamic components, with nicely designed UI that makes user-experience painless.

What makes this site so Web2.0 is that the serach filter and sort functions that allows users to select manifactures/brands, price ranges, and other choices with slider, and allows to rate the products they own.

I'd say this site is one of the best demo to show off what they are doing with Yahoo! Design Patter Library.

(This blog entry was originally written on May 3 for my other blog and copied it on Blogger on Sept.26)