Let's Get Started With GOOGLE MAP!!

Finally, we've got our conclusion about what we're going to do this year. And it involve with google map. So better start studying it today shall we?

Today i'm going to talk about how to integrate GOOGLE MAP in your website. And i'm going to explain and guide you how to place marker on your custom map.

1. Sign up Beta Key. Go here. Put your website url in the box below.

2. Copy javascript from example in key page For example

 

3. Now, start writing a simple HTML

 

<html><head>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAeImax-ZV27pxekFFvP............lFgTumTUvfA6Ng" type="text/javascript"></script>
</head>
<body></body>
</html>

Put script from the key above in the head area. And Edit the From Sensor=true_or_false to Sensor=true

4. After that, in the body. Put Div tag which you want it to be canvas of the map in

<div id="mapCanvas" style="width: 800; height: 600"></div>

5. Put another javascript in HEAD tag. This will be custom thing you're going to add script afterward.

<head>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAeImax-ZV27pxekFFvP............lFgTumTUvfA6Ng" type="text/javascript"></script>
<script type="text/javascript">
function initialize(){
var map = new GMap2(document.getElementByID("mapCanvas"));
}
</script>
</head>

This function will be called everytimes the body of page loaded. var map = new GMap2(document.getElementByID("mapCanvas")); Will build new GMap Object from library retrieve from Google Website.

6. after map builded. Add Custom code to customize the map. Such as set map center view.

map.setCenter(new GLatLng(13.793697,100.325303), 13);

Set to Latitude and Longtitude using object Called GLatLng with Zoom Level = 13.

7. Add additional function map.setUIToDefault(); to add mouse zooming functionality.

8. Edit BODY Tag to call this function everytimes it start.

<body onload="initialize()" onunload="GUnload()"> Add GUnload to prevent Memory Leak.

9. Now Test It here.

10. You can add custom overlay to map, such as marker or additional information. Then use methed map.addOverlay() method.

map.addOverlay(new GMarker(new GLatLng(13.793635,100.326054)));

now We've got a marker point to our building.

That's All For today. Hope i'm coming up with new thing to update you guy! have Fun with google map Kub

Categories:   Javascript | Tip(s)
Actions:   E-mail | del.icio.us | Permalink | Comments (7) | RSS


Comments

June 18. 2009 19:46

hara

Oh thanks so much. I confuse for long time how to get the google map in site
:3

hara

June 18. 2009 21:43

TSAdvanced

Looking FWD to your coming project.

I've messed with Google map API but never programmed it. (Only use it)

TSAdvanced

June 19. 2009 11:34

The-Q

I have been waiting for a long time for this one!!!

The-Q

June 25. 2009 20:39

trackback

Find Direction From Your home to AnyWhere?

Find Direction From Your home to AnyWhere?

theBlogfor.NET

July 14. 2009 13:06

Jacques Lemans

I like how you write.Are you interesting in a part time writer job?

Jacques Lemans

August 10. 2009 05:23

payday loans

Keep working ,great job!

payday loans

August 12. 2009 05:21

cash loans

Very, very cool site site! I am loving it!! Will come back again - taking you feeds also, Thanks.

cash loans

Add comment




biuquote
  • Comment
  • Preview
Loading



 

Tag Cloud