In a previous post we saw how to add a Google Map to blog. Sometimes having a simple map is not enough. Markers are used on a map to identify points on the map. See picture below (Click on picture to enlarge it):
In above picture you can see a Google Map with Markers in my test blog. Here are the steps to put such a map in your blog......................
STEP 1. Get a Google API key for your blog.
In the first step you have to generate a Google API key for your blog here.
Put a check in "I have read and agree with the terms and conditions (printable version)" box by clicking it. Paste your blogspot URL in the text box and click Generate API Key button. Copy down the key generated.
STEP 2. Modify the Template Code.
Login at Blogger.com
Click Layout link under Blog Title on Dashboard.
Click Edit HTML subtab of Layout tab.
Scroll down in Template Code box and change :
<body>
TO :
<body onload='initialize()' onunload='GUnload()'>
Save Template.
STEP 3. ADD HTML GADGET in sidebar.
Login at Blogger.com
Click Layout link on Dashboard under blog title.
Click Add Gadget link on Page Elements subtab of Layout tab.
In popup window scroll down and click HTML/Javascript Gadget.
Copy the code below and paste it in Contents window of the HTML gadget :
<script src="http://maps.google.com/maps?file=api&v=2&key=PASTE_YOUR_GOOGLE_API_KEY_HERE"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(latlng));
}
}
}
</script>
<div id="map_canvas" style="width: 500px; height: 300px"></div>
Customize the above code by :
1. Paste in the Google API key obtained in Step 1 where it says "PASTE_YOUR_GOOGLE_API_KEY_HERE".
2. Put in the latitude and longitude of your map center in this line :
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
3. The above code will add 10 markers at random locations. For more information checkout the Google Maps documentation.
Save Gadget.
Google Map with Markers in Blog. |
Valentine's Day Wishes from Eiffel Tower Paris. |
Imagine sending Valentine's Day Wishes from the top of the Eiffel Tower, Paris and any other site in the world including from your own residence. You can even send it from the Eiffel Tower, Las Vegas, the Pentagon, the Pyramids of Egypt, the Colosseum at Rome, the Statue of Liberty and any prominent landmark on the globe. Technorati Tags:valentine day, google map
To do this go here. Type in the name and location of the place you want to send the greeting from in Address text box or choose one of the places from the visit text box and once the map has navigated to the place position the red marker on topof the building from where you want to send the message. Click Next and type your message and then click Next again to type in your email address and the recepient's address. Then Preview and Send. See the images below from the Eiffel Tower, Paris :

Mumbai Marathon Map Pedometer. |
The Mumbai Marathon will be held on 21 st January 2007. For marathon afficionados and fitness enthusiasts and those training for the Mumbai Marathon here is a way to map the route and see how many calories you will spend....... Technorati Tags:mumbai marathon, gmaps, pedometer, google, google map,
For doing this we will use an online pedometer which uses Google Maps to measure distances and also gives the amount of calories spent. There is also an elevation profile (only for US maps at present). The route can be measured in Kilometers or miles. After measuring out the route you can save the route as a webpage and send the link to your friends. You can use this site to measure your daily morning run or evening walk anywhere in the world.
You can zoom in and see the details on the route or zoom out to see the route in its entirety. To do this use the zoom and pan tool at the upper left hand corner of the map. Click on the plus sign to zoom in and the minus sign to zoom out.
To start go to Gmaps Pedometer. The default map shown is of North America.
Click on Image for larger view
Click on the map and drag to navigate on the map to your city (in this case Mumbai). The top of the map has four options :Map, Satellite, Hybrid and Topo. Click on the Hybrid option on the top of the map. This is because Google does not have road maps for all the cities.
Click on Image for larger view
Using the vertical slider at the top left corner of the map zoom in till you come to the maximum magnification possible. This lets you see the roads and buildings. When you have identified your starting point choose whether you wish to record the distance in miles or kilometers. See Image below where I have zoomed into the start of the Mumbai Marathon at Chatrapati Shivaji Terminus at Mumbai India.
Click on Image for larger view.
Turn on the mile markers and turn on the calorie counter after entering your weight.. Choose the elevation if you are mapping a route in the US..
When you are ready Click on the Start Recording Button.
Go to your starting point on the map and double click on the starting point. A starter marker appears at the location. Doubleclick on the next point on the route and a red line appears linking both the points. The map moves to center itself on the new point. Continue in this fashion along the route and a red line marks out the whole route. Markers are placed along the route and the distance and calories are counted as you progress. At any time along the route you can backtrack at any point by clicking on Undo last point button. See Image alongside where I have mapped out the whole Mumbai Marathon. You can see the whole route for yourself by going to Mumbai Marathon Map.. For a larger view drag the vertical slider at the top left corner of the map downwards. To zoom in drag it upwards. To scroll the map in any direction click on the arrows at the top of the left corner or just click and drag on any area of the map surface. Here are more images of the route :

Click on Images for a larger view.
After finishing the route save it by clicking on Save Route. The route is saved as a webpage. You can send this link to anyone. In this manner you can map out your daily morning run anywhere in the world.
Add Google Map Search to Blog. |
To add a Google Map Search to your blog.........
go to http://www.google.com/apis/maps/ and click on the Sign up for a Google Maps API key button. It will take you to this page :
http://www.google.com/apis/maps/signup.html. This key identifies your web site to Google and helps them track usage of Google Maps. A new and distinct key is needed for each directory on your website that includes Google Maps.
Put a check in the box where it says I have read and agree with the terms and conditions and paste your blog url in the text box below and click on Generate API Key button.(Step 1)
Copy paste this code (ONLY THE BLUE LINES) just below the title tag in your template :
<!-- maps api, ajax search api, map search solution code -->
<script src="http://maps.google.com/maps?file=api&v=2&key=YOUR-KEY"
type="text/javascript">
IN THE ABOVE LINE ADD amp; AFTER BOTH THE & CHARACTERS OR YOU WILL GET ERROR MESSAGE.
</script>
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=YOUR-KEY"
type="text/javascript">
IN THE ABOVE LINE ADD amp; AFTER BOTH THE & CHARACTERS OR YOU WILL GET ERROR MESSAGE.
</script>
<script src="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.js"
type="text/javascript"></script>
<!-- ajax search stylesheet, map search stylesheet -->
<link href="http://www.google.com/uds/css/gsearch.css" rel="stylesheet"
type="text/css"/>
<link href="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.css"
rel="stylesheet" type="text/css"/>
Type in your Google API key code where it says 'YOUR KEY ' above.(Step 2)
Define a location on your page for the Map Search Control (Step 3)
It is necessary to have an empty space in the right hand part of the body of your template to add this in the way I have done. I have used the Minima template and added a float left property to the outside wrapper to create room for the Google Map on the right side.
This is typically done by defining a named <div> element as we have shown below:
Then paste this code in your template just after <body> tag :
<div id="mapsearch">Loading...</div>
You might want to set some styling attributes on this element to constrain the width of the control, set a border or margin, etc. For example, a style rule like this might be useful.
Add the following to the CSS part of your template
#mapsearch {
width : 400px;
float:right;
margin : 10px;
padding : 4px;
border : 1px solid #f9f9f9;
}
You can change the width to suit your blog.
In addition to this base style, the height of the idle state map and the active state map is easily modified.
/* set height of idle state map */
#mapsearch .gsmsc-idleMapDiv { height : 200px; }
/* set height of active state map */
#mapsearch .gsmsc-mapDiv { height : 300px; }
to get code to run add this code after the <body> tag (Step 4)
<body onload="OnLoad()">
After the above line add the following code which will create a map that will center itself on Google corporate headquarters located at "1600 Amphitheatre Parkway, Mountain View, CA.":
<script type="text/javascript">
function OnLoad() {
// set title to the Googleplex and the link to
// the Google corporate information page
var options =
{
title : "Googleplex",
url : "http://www.google.com/corporate/index.html"
}
// create the map search control
new GSmapSearchControl(
document.getElementById("mapsearch"),
"1600 Amphitheatre Parkway, Mountain View, CA",
options
);
}
</script>
To display the map of any other place in the USA add code similar to this line :
"1000 NE Multnomah, Portland, OR",
("Place Location, CITY NAME, STATE",)
instead of this line in above code :
"1600 Amphitheatre Parkway, Mountain View, CA",
To Set up hot spots (Step 6) add this code in the css to style the hotspots :
/* define the CSS used to style the hotspots */
h4.hotspot {
font-size : 100%;
font-weight : normal;
color : rgb(9, 122, 182);
margin-left : 8px;
margin-top : 0px;
margin-bottom : 2px;
font-style : normal;
cursor : pointer;
}
h4.hotspot:hover {
color : rgb(237, 92, 11);
text-decoration : underline;
}
To show the hotspots on the page add the following code after the mapsearch div code added in Step 3
<h3 class="hotspotheader">Recommendations</h3>
<h4 id="hs01" class="hotspot">Caffeine</h4>
<h4 id="hs02" class="hotspot">Thai Food</h4>
<h4 id="hs03" class="hotspot">Pizza</h4>
<h4 id="hs04" class="hotspot">Gym</h4>
<h4 id="hs05" class="hotspot">Hotel Avante</h4>
<h4 id="hs06" class="hotspot">Residence Inn</h4>
<h4 id="hs07" class="hotspot">The Four Seasons</h4>
<h4 id="hs08" class="hotspot">The Westin, Palo Alto</h4>
To create the hotspots use the following script :
// Create an array of hotspots. Each entry contains and html element
// from your page, and the query to execute when that element is clicked
var hotspotsList = [
{ element : document.getElementById("hs01"), query : "Starbucks" },
{ element : document.getElementById("hs02"), query : "Amarin Thai" },
{ element : document.getElementById("hs03"), query : "Frankie Johnnie Luigi" },
{ element : document.getElementById("hs04"), query : "Hotel Avante" },
{ element : document.getElementById("hs05"), query : "Residence Inn" },
{ element : document.getElementById("hs06"), query : "Four Seasons Palo Alto" },
{ element : document.getElementById("hs07"), query : "Westin Palo Alto" }
];
// set title to the Googleplex and the link to
// the Google corporate information page
// set the hotspot list to the list above
var options =
{ title : "Googleplex",
url : "http://www.google.com/corporate/index.html",
hotspots : hotspotsList
}
// create the map search control
new GSmapSearchControl(
document.getElementById("mapsearch"),
"1600 Amphitheatre Parkway, Mountain View, CA",
options
);
}
</script>
Click above image to enlarge it.
To test it go to :http://googlesearchmap.blogspot.com/
Technorati Tags:google map, google map search
Add a Country Map to your Blog. |
To add a country map to your blog............ Technorati Tags:ajax search, country map, google map, map marker
first you willhave to follow the instructions in Add a Google Map to your blog. (Step 1) After having added the map to your blog you need the Latitude and Longitude of the point on earth where you want to center your map. Do this by entering the place name in Google along with the words 'latitude longitude' and pressing Search.
Google will give the coordinates of Latitude and Longitude for that place. Enter these figures in the following line of code in your template (Step 2). This line of code is there in your template because you entered it in Step 1 above.
map.setCenter(new GLatLng(37.4419, -122.1419), 5);
The figures in brackets are the Latitude and the Longitude of the place where you want to center the map. The next figure - 5 - is the zoom factor. NOTE that Google does not have the same detailed maps of the entire planet. If you enter a very large number here the map will not come up on the page. So start with a small figure like 5 and increase it till Google says it does not have more detailed maps.
I have added the map of India as shown in following picture :
Click on Image for larger preview.
Now you will want to add some place markers to the map. First create an image representative of the place where you will place the marker and save in PNG format. Then upload the image to a freeserver like Googlepages and copy down the url (Step 3). Then in your blog template add the following lines just after the line you added in Step 2 to the template :
var point = new GLatLng(18.96,72.82);
var marker = createMarker(point,'<div style="width:240px">NAME OF PLACE<br /><a href="MY SITE URL">Link</a> to my home page<br /><img src="URL OF PLACE IMAGE" width=XXX height=YYY></div>')
map.addOverlay(marker);
Enter the Latitude and Longitude of the place where you want to place the marker in line 1 of the above code. Enter the place name instead of 'NAME OF MY PLACE'. Enter your site link url instead of 'MY SITE URL'. Enter the url of the image you noted down in Step 3 instead of 'URL OF PLACE IMAGE'. Enter the width and height of the image in pixels instead of XXX and YYY.
Save Template. See the image above where I have added it to Delhi. To see this map in action go to Google Ajax Made Easy. and click on the marker for Delhi.
Add a Google MAP to your Blog. |
Skip to POST UPDATE. Technorati Tags:google, google map
To add a Google Map to your blog go to ..........
http://www.google.com/apis/maps/ and click on the Sign up for a Google Maps API key button. It will take you to this page :
http://www.google.com/apis/maps/signup.html. This key identifies your web site to Google and helps them track usage of Google Maps. A new and distinct key is needed for each directory on your website that includes Google Maps.
Put a check in the box where it says I have read and agree with the terms and conditions and paste your blog url in the text box below and click on Generate API Key button.
Copy paste this code (ONLY THE BLUE LINES) just below the title tag in your template :
<script src='http://maps.google.com/maps?file=api&v=2&key=YOUR KEY' type='text/javascript'>
IN THE ABOVE LINE ADD amp; AFTER BOTH THE & CHARACTERS OR YOU WILL GET ERROR MESSAGE.
</script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 5);
}
}
//]]>
</script>
Type in your Google API key code where it says 'YOUR KEY ' above.
Save Template. The addControl line adds a small pan and zoom control to the map. The next line centers and zooms the map to that latitude and longitude at zoom level 5.
Then paste this code inyour template just after <body> tag :
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
Save Template.
Paste this code in the css part of your template :
#map {
float:right;
margin:10px 20px 10px 10px;
}
Save Template
See how I have added it to my test site : http://googlemapdemo.blogspot.com/
Click on image below for larger view.
IMPORTANT : It is necessary to have an empty space in the right hand part of the body of your template to add this in the way I have done. I have used the Minima template and added a float left property to the outside wrapper to create room for the Google Map on the right side.POST UPDATE
Google Maps Has now made it possible to easily add Maps to your blog. Go to http://maps.google.com/ and navigate to the location you wish to show. Click on 'Link to this Page' Link on the top right hand corner of the map. In the drop-down copy the EMBED code under 'Paste HTML to embed in website'. Login at Blogger.com and click on '+New Post' link on Dashboard. The Post Editor will open. Click on Edit Html tab and paste the EMBED code there and publish.
You can adjust the width and height in the code to fit your post.
For example :
View Larger Map
You can also paste the code in a Html Page Element in the sidebar.












