Sunday, October 25, 2009

Google Map API V3 tutorial


Every one on web know Google map,Best mapping from google .But some know about the google map API and it’s very easy to use.

It’s great news that google released new version of google map API version 3.
The previous version will continue(V3).Nevertheless as a beginner to google map API I recommend Version 3 because it has great added advantage over Version 2 .
Some of the the advantages I noticed include

You need only develop a map it can run on android phones,website,iphone
and speed .
Other advantages we discuss later in this article.

For those who are beginner with google map go with v3 and those who want to switch from v2 this is the best time.because google map is in Labs and when it become full fledged you can go your study parallel.

About the API

Google map API is available to you in javascirpt language .You can integrate it with any of your server side programming like PHP,ASP.net JSP etc .

The previous version of API used a unique key for each user they want to use map in their application


For example if codeglob.blogspot.com want to use google map api v2 we have to sign up for the api using the site url and google account, a unique key is generated for you website.
Things have changed here is the happy news .You don’t need to use a API key for the Map API V3.

How to setup

We already told that MAP api is Javascript API .We need to add reference in our webpage.

<script type=”text/JavaScript” src=”http://maps.google.com/maps/apis/js?sensor=false”>
</script>

By doing this you added the reference to Google map API in your webpage.
Only thing you remember when referencing to google map is setting the sensor parameter

sensor = true/false this tells the map api whether you are using GPS sensor or not .


Next we look at the how we can initialize the map

Map needs a canvas to draw ,ie area in webpage usually used <div>

So create a div and give a id for the div

Eg:

<div id=”map”></div>

inorder to specify the width and height of the div specify a css style in page in style tag or external css file.

<style type=”text/css”>
#map
{
height:300px;
width:300px;
}
</style>

API v3 use JSON (Javascript Object Notation) for creating object .It’s easy when we use javascript object to set values.

Eg: We have an object car and it have some properties like color,tyre,type,make,model etc we can create a Javascript object of car like this

Car
{
color:red;
tyre:4;
make: Hyundai;
model:i-20
};

like this in Map Api uses some javascript objects. To access object property just call it like

alert(Car.color);

Map initialization


Map uses latitude longitude value( a particular point in map) .Setting initial latitude and longitude is like this

var latlng = new google.maps.LatLng(‘latitude value’,’longitude value’);

To initialize map we need to call the contructer of the class Map in Google map API.It takes two arguments one is the canvas that we need to draw the map HTML element .We already told that we setup div named map for showing map. And the second argument is the map otions.Map options is given in the format of JSON. .
So we create a options object having the folloging format
//Properties of the map
Options
{
zoom:16;//map has 0-19 zoom levels
center:latlng;// previously declared Latitide Longitude variable
mapTypeId: google.map.MapTypeId.ROADMAP;// Google map Type
};

Google map Support four types of maps
ROADMAP
HYBRID
SATELITE
TERRAIN

Next we call the constructer by passing the values to initialize the map.

Var map= new maps.google.Map(document.getElementById(‘map’),options);

Then the map is visible to you when you browse the page in browser.

Complete sample code for Google map Initialization

Adding marker and Info Window to the map


var marker= new google.maps.Marker({
position: new google.maps.LatLng(9.099761549253056,76.5246167373657),
title: "Hello Testing",
clickable: true,
map: map
});


var infiwindow = new google.maps.InfoWindow(
{
content: “Hello"

});


google.maps.event.addListener(marker,'mouseover',function(){
infiwindow.open(map,marker);
});
google.maps.event.addListener(marker,'mouseout',function(){
infiwindow.close(map,marker);
});

Here is the sample complete code for this article

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Google Map Test </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize()
{
var latlng = new google.maps.LatLng(9.931544168615512,76.27632894178791);
var opt =
{
center:latlng,
zoom:10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableAutoPan:false,
navigationControl:true,
navigationControlOptions: {style:google.maps.NavigationControlStyle.SMALL },
mapTypeControl:true,
mapTypeControlOptions: {style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}
};
var map = new google.maps.Map(document.getElementById("map"),opt);
var marker= new google.maps.Marker({
position: new google.maps.LatLng(9.931544168615512,76.27632894178791),
title: "CodeGlobe",
clickable: true,
map: map
});


var infiwindow = new google.maps.InfoWindow(
{
content: " I am here! "

});


google.maps.event.addListener(marker,'mouseover',function(){
infiwindow.open(map,marker);
});
google.maps.event.addListener(marker,'mouseout',function(){
infiwindow.close(map,marker);
});


}
function test(event)
{

alert( event.latLng.lat());
alert(event.latLng.lng());

}
</script>
<style type"text/css">
#map{
width:500px;
height:500px;
float:left;
position:absolute;
left:300px;
top:200px;

}
</style>
</HEAD>

<BODY onload="initialize();">
<div id="map" >

</div>
</BODY>
</HTML>

If you have any problem implementing google map API please mail me: irshadcp at gmail dot com

Monday, October 19, 2009

Zion Dengon 1.0 Beta

Redefine the way of SMS ing...Download.



Zion Dengon is an application that allows you to send messages in two ways
1.Using normal way.
2.Using way2sms account(you need GPRS enabled phone)

The key features and functionalities
1.You can maintain your own contact list and from those contact you can select multiple users and add to your message recipients.
2.It is the modifed version of Zion SMS Mania and combined version of Zion SMS and Zion SMS Mania.
2.You can add your contact member in two ways
a)By using the add contact option
b)By browsing your phone contact
I prefer the first way in this case you just need to enter the name of the person and if his/her number is already in your phone contact you have option to browse that number,and then you can add it to the Zion Dengon contact.
In the second way you don't need to type anything,just select the contact list that exist in your phone shown in the multi selection list,you feel this as more easy but actually it is more time consuming.
Note:Never add all the contacts at a a time(in option b) it will take more time to do and show in list.

For more details contact-email:xpedition009@gmail.com

Enjoy SMS ing..

Thursday, October 15, 2009

HTML Form elements array

Creating array of HTML form elements

Array is a collection of similar data elements, means we can use array to store similar elements referenced under a common name.


In web development sometimes we need to group HTML form elements as arrays do. For example, you have a form where user has to select his hobbies from a group of check boxes as given below.










Sample Code
<form action="showlist.php" method="post" name="hobby_frm">
<h3> Select your hobbies </h3>
<input type="checkbox" name="hobbies[]" value="hb1"  />
Reading <br />
<input type="checkbox" name="hobbies[]" value="hb2" />
Surfing <br />
<input type="checkbox" name="hobbies[]" value="hb3" />
Listening to music  <br />
<input type="submit" value="submit" />
</form>
Please notice the name of all checkboxes hobbies[]
The above code will define an array with the name hobbies

Accessing form elements array using JavaScript

Now, let's see how to access the hobbies[] using JavaScript.
<script type="text/javascript">
var hobbies = document.hobby_frm.elements['hobbies[]'];
var str = "Length  : "+hobbies.length+"\n";
for( var i = 0; i < hobbies.length; i++ ) {
str = str + "Hobby "+(i+1)+" : "+hobbies[i].value+"\n";
}
alert(str);
</script>
Handle form elements array in PHP

In PHP, data sent from a form with post method is available in $_POST array.
We can access hobbies[] using the following code.


<?php
$hobbies = $_POST['hobbies']; // use name of the array as key
foreach( $hobbies as $value )
print $value;
?>



courtesey webdevelopment hosting company cochin kerala

Friday, October 9, 2009

Zion Plus-2010(Beta)


Manage text files in your mobile phone in a more flexible manner..Download.

A new release of previous version of Zion Plus..More functionalities and a new look..useful and flexible than the previous version..try it today itself..

Its a Beta version modifications and performance issues will be updated in the coming versions..

An application that allows you to create text files in phone memory and memory card. If you want to create folder in your mobile through this application edit the "directoy" field,shown when you choose save or save as option. for eg: the directory field shows -"file:///e:/folderx/" you can create a folder "NEWFOLDER"in that directory by changing the field by "file:///e/folderx/NEWFOLDER/" You can specify the file name in the filename textbox,default name will be newfile. Help menu to assist you in how to use this application.

Wednesday, September 30, 2009

The maximum nuber of hosts possible in an organization with the address 200.25.18.0/23

Wednesday, September 23, 2009

Lost Task Manager? alternate solution!

It is often happens the very annoying alert message in the windows operating system, "Task manager has been disabled by the administrator!" really??. This is because of some malicious program being run in the back ground and it is normally invisible to the user. The only easy way to monitor this simply the task manager! right?. Task manager is a graphic tool used to monitor the current running process and applications and related details of these.

it is happy to know that the malicious program writers or the virus writers are really scare with this Task manager. A experienced administrator can easily find out
with the help of this task manager what are the suspected programs running in the background other than the normal programs. consequently their program process could be stopped by the administrator. In order to prevent this these ugly guys often programmed into disable the task manager.

Task manager can be re enabled in a file using "gpedit.msc" in the administrative templates that is there.But the "ugly" writers are more than of that when we re enable the task manager, within seconds or less than of second they will disappear it again.This means the malicious program still running in the background and must be stopped right?

Here is the solution...
netstat command could be used for alternative of to identify what are the program running in the background according to their name,memory usage and process ID.
here is a brief description of netstat with very useful options.


netstat -anbo

-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection
-a Displays all connections and listening ports
-b Displays the executable involved in creating each connection or
listening port.


the above command in the cmd will result a detailed status of the program with name, process id, including the dll fles etc.

simply use the process id to input to the "tskill" command.

ex.
tskill 8299

where 8299 will be the process id of suspected process.And this is one of the ways you can achieve this task right?.

regards..

Sunday, September 20, 2009

Struts2 align check box vertical

Normally the struts checkboxlist in struts2 diaply the check boxes horizontally. In most of application we want to
display the check boxes vetrically ie line by line. For aligning this as vertical we have to do as specified below
1) You have to create a directory template in your src folder
2) create a folder with name of the template you want to create (vertical-checkbox)
3) copy the struts-2.1.6/src/core/src/main/resources/template/simple/checkboxlist.ftl file to this directory content of this file is as follows. Before the </@s.iterator> you have to put a <br> tag as I given in this

<#--
/*
* $Id: checkboxlist.ftl 720258 2008-11-24 19:05:16Z musachy $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<#assign itemCount = 0/>
<#if parameters.list??>
<@s.iterator value="parameters.list">
<#assign itemCount = itemCount + 1/>
<#if parameters.listKey??>
<#assign itemKey = stack.findValue(parameters.listKey)/>
<#else>
<#assign itemKey = stack.findValue('top')/>
</#if>
<#if parameters.listValue??>
<#assign itemValue = stack.findString(parameters.listValue)?default("")/>
<#else>
<#assign itemValue = stack.findString('top')/>
</#if>
<#assign itemKeyStr=itemKey.toString() />
<input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
<#if tag.contains(parameters.nameValue, itemKey)>
checked="checked"<#rt/>
</#if>
<#if parameters.disabled?default(false)>
disabled="disabled"<#rt/>
</#if>
<#if parameters.title??>
title="${parameters.title?html}"<#rt/>
</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
/>
<label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
<br>
</@s.iterator>
<#else>

</#if>

4) <s:checkboxlist list="urlist" name="selectedValues" listKey="id" listValue="descrption" theme="vertical-checkbox"></s:checkboxlist>
this will give you vertical check box list
only difference is that here you have to specify the theme which is same as the directory u have created in the template directory in the src folder of your project

LinkWithin

Related Posts with Thumbnails