Thursday, April 19, 2012

Create your own mini google map Search Engine

First of all see the example

in this demo  google api is used for Map and searching
Markers and search box is placed custom.

this is just a standalone HTML code you can copy and paste to your favourite writer
and save as html.

for doing such a thing use following code

     Created By : Yogesh Prajapati
           Date : 28 March 2011

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xmlns:v="urn:schemas-microsoft-com:vml">
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title> Search Demo </title>
        <script src=";v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"

        <script type="text/javascript">
            var map;
            function initialize() {
                if (GBrowserIsCompatible()) {

                    function doGenerateMarkerHtmlCallback(marker,html,result) {
                        html.innerHTML+="<b>Result Coordinates: "","+result.lng+"</b><br>";
                        html.innerHTML+="<b>Marker Location: "+marker.getLatLng().toUrlValue()+"</b>";
                        return html;

                    var options = {
                        resultList : document.getElementById('results'),
                        onMarkersSetCallback : function(markers) {
                        //onGenerateMarkerHtmlCallback : function(marker, div, result) {div.innerHTML = result.title + "<br/>"; return div; }

                    map = new GMap2(document.getElementById("map_canvas"), {googleBarOptions: options});
                    map.setCenter(new GLatLng(23.450, 72.483), 8);
                    map.addControl(new GSmallMapControl());

                    var myLayer = new GLayer("");


            function deleteAllRows()
                for(var i = document.getElementById("tblResult").rows.length; i > 0;i--)
                    document.getElementById("tblResult").deleteRow(i -1);
            function setCenterOnMap(lat,lng){
                map.setCenter(new GLatLng(lat,lng), 15);

            function fillTable(markers){
                var table = document.getElementById('tblResult');
                var counter=65;
                    var row = table.insertRow(i);
                    var cell0 = row.insertCell(0);
                    var  newImage = "url(" + String.fromCharCode(counter) + ".png)";
           = newImage;
                    var cell1 = row.insertCell(1);
                    cell1.innerHTML = "<a href=javascript:void() onClick=javascript:setCenterOnMap(" + markers[i].marker.getPoint().lat() + "," + markers[i].marker.getPoint().lng() + ")>"  + markers[i].result.title + "</a>";

                    //alert(markers[i].marker.getPoint().lat() + " - " + markers[i].marker.getPoint().lng());

    <body onload="initialize()" onunload="GUnload()" style="background-color:aliceblue">
        <table border="0" width="100%" >
                <td style="width: 250px;" align="center" style="vertical-align: top">
                    <div id="results" style="visibility: collapse;height: 0px"></div>
                    <table border="0" width="100%" style="height: 450px">
                            <td style="height: 10px">

                                <table border="0" width="100%">
                                        <td align="right" style="width: 65px">
                                            <img src=""/>
                                            &nbsp;&nbsp;Search Results
                                <table border="0">
                                            <img src="myLine.png" width="210px" height="1px" style="vertical-align: top"/>
                            <td style="vertical-align: top">
                                <table id="tblResult" border="0" width="100%" cellspacing="5" >
                    <div id="map_canvas" style="width: 100%; height: 550px;"></div>
                <td align="right" colspan=2>
                    Demo Created By : <b>Yogesh Prajapati</b><br/>



for any help related to Map contact.....

No comments:

Post a Comment

Disqus for yogi's talk

comments powered by Disqus