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

Saturday, November 6, 2010

Your First Google Map Application

Sometimes you need to add a map to your location in your site so that the users can reach you easily. what i like about Google maps is their API, it is very structured , easy to understand and the documentation is excellent.

So follow me in the next few steps:

1.You need to register a key

go to http://code.google.com/apis/maps/signup.html , and enter your site URL. your key will be generated and you will find a lot of ways to include Google Maps , here we will include Google Maps into web pages using Javascript.

for example

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


i totally recommend you to keep an eye on the documentation 


http://code.google.com/apis/maps/documentation/javascript/v2/reference.html
3. Map.html 

<html>
    <head>
        
        <title>My First Google Map</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAt_j1jxA-
OrN2zgFscf196hQ81ypfsrwFppodUYGd3WJUYwK81BQMmvl7uCUsxJJdrC9XnVo-dI7fZQ" type="text/javascript"></script> 
<!—Google.js is the file that will define RenderMap(DivID)-->
   <script src="Google.js" type="text/javascript"></script>
        <script type="text/javascript">
            function LoadMap () {
                RenderMap('GoogleMap');  
            }
            window.onload=LoadMap; 
        </script>
    </head>
    <body>
        My Map will be in this Div 
        <div id="GoogleMap" style="width:500px;height:500px;">
        </div>
    </body>
</html>
4. Google.js
function RenderMap(DivID)
{
var MapDiv = document.getElementById(DivID);
var GoogleMap = null; 
if (GBrowserIsCompatible()) {
GoogleMap = new GMap2(MapDiv);

//Add Navigation Control and Zoom Control on the Map
GoogleMap.addControl(new GSmallMapControl());
GoogleMap.addControl(new GMapTypeControl());

//Enable Scrolling on the Mouse Wheel
GoogleMap.enableScrollWheelZoom();

//Next we will add a marker to our company 

//Company Latitude And Longitude
//You can get your Latitude And Longitude From Google Earth , i entered random values
var CompanyLongLat = new  GLatLng(29.449790329784214, 28.9599609375); 

//Company Marker On The Map
var CompanyMarker= new GMarker (CompanyLongLat) ;


//we need to add a "left click" event to the marker 
//when the user click on the marker , a balloon will appear that has the address information 
GEvent.addListener(CompanyMarker,"click", function() {
var AddressInfo= 'My Address Information'; 
CompanyMarker.openInfoWindowHtml(AddressInfo);
});


//Finally , add the Company Marker to the map 
GoogleMap.addOverlay(CompanyMarker);

GoogleMap.setCenter(CompanyMarker.getLatLng(),10);
}

}








That is all , Enjoy


Friday, September 3, 2010

Google Translator is using “Statistical Translation Machine”

Before i start the article , i want to send a message to a group of idiots that said “Google Is using Rule Based” , the amazing thing is they don’t know the difference between them , so if you still don’t know the difference , i will show you the difference in this article so you can be in the safe side not the idiot side.

Rule Based Approach:
you will spend a lot of years building this engine and you wont get  good results in the end.

summary :

at this approach you have a dictionary that contains the two languages that you will translate from and to the other. then you have an engine that contains your language rules and their exceptions. when you translate you keep in mind the subjects , adverbs , verbs , ….etc. in both languages .

Statistical Translation Machine:
All what you need is data !

summary:

it simulates the way humans learn a new language , when you learn a new language you wont necessarily need to know the rules of the language , you will need to know the sentence in Arabic and its English equivalent.
first you need data , the data in this approach is any piece of text and its translation , then the algorithm tries to find a pattern in the data , based on the frequency of the text.
here is a reference
http://translate.google.com/about/intl/en_ALL/