JavaScript – Google Maps With Pointer

Google Map API is an interface for you to put maps on your webpage. It also can be used as an input method for a user to select his address exactly on a map. So, the user does not only type in his address, city, country and other location information as we can found generally on ordinary submit forms. They mark their exact address on the map. Sounds great, isn’t it? Google map API is generally used in real estates websites to provide a more informative and readable detail.

Demo

To move the marker, you may perform a single right click on a new location.

Source Code

<html>
    <head>
        <title>Google Maps API Example</title>
        <script
            src="http://maps.google.com/maps?file=api&v=1&key=<your api key>"
            type="text/javascript">
        </script>
        <!--
            <your api key> is a unique key provided by google map
            You have to replace <your api key> with your api key
            You can get your API key at
http://code.google.com/apis/maps/signup.html
        -->
    </head>
    <body>
        <div id="map" style="width:400px;height:400px"></div>
        To move the marker, you may perform a single right click
        on a new location.
        <script language="JavaScript">
            //By    : Xhanch Studio
            //URL   : http://xhanch.com/
            var map;
            // Define default marker location
            var default_longitute = "-122.141944";
            var default_latitute = "37.441944";
            // Marker/Pointer moved handler
            function move_marker(latlng){
                if(latlng){
                    //Get the selected corrdinate
                    lng = latlng.lng();
                    lat = latlng.lat();
                    //Remove all markers
                    map.clearOverlays();
                    //Set new marker
                    var point = new GPoint(lng, lat);
                    var marker = new GMarker(point);
                    map.addOverlay(marker);
                }
            }
            // Google Map initialize
            if (GBrowserIsCompatible()) {
                map = new GMap(document.getElementById("map"));
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
                //Set default marker, the zoom we set to 7
                var point = new GPoint(default_longitute, default_latitute);
                map.centerAndZoom(point,7);
                var marker = new GMarker(point);
                map.addOverlay(marker);
                // Assign a single right click event handle
                GEvent.addListener(map, "singlerightclick", function(point){
                    var latlng = map.fromContainerPixelToLatLng(point);
                    move_marker(latlng);
                });
            }
        </script>
    </body>
</html>

Incoming Search Terms

source code php right click and add marker place to google map, fromcontainerpixeltolatlng, gevent addlistener right click, google map pointer, google maps pointer, gevent addlistener rightclick, google pointer, javascript google map, google map php moving marker, gevent addlistener(map rightclick, javascript pointer map, google maps marker click singlerightclick, right click google maps gevent, javascript google map location pointer, javascript google maps pointers, google maps with pointer, google maps pointer javascript, javascript pointers for google maps, wordpress pointer api, map pointer javascript, \singlerightclick\ point, singlerightclick google maps, map pointer script, Google map with pointer, javascript search google maps, map fromContainerPixelToLatLng(point), latlng singlerightclick, location pointer in google map in javasript, javascript mark point, map fromcontainerpixeltolatlng in javascript, javascript pointer google, map fromContainerPixelToLatLng, javascript map single address, javascript goolge maps, how to add google map pointer in java, how to add pointers in google maps, how to put a pointer on a map, green marker for source and destination google maps using javascript, how to put pointers on google Map, how to puy destination pointers on google maps, how to show maps with pointers in java script, how to show pointer in google map, i need to point 2 pointers on gmap one is source and other is destination using javascript, include google maps with pointers in website, java script for put pointer in google map, javascript coding for displaying source and destination in google map, javascript for google maps, javascript code to search location in google map, javascript for putting a map with markers on a webpage, how to add a pointer to google map api, map fromcontainerpixeltolatlng(points) google maps, map pointer in javascript, right click on google earth to put a marker, right click on google map java script code, script pointer google map javascript, script search point nya google map, search as google maps in php javascript, Search marker GEvent addListener, select javascript:marker click, singlerightclick, singlerightclick get latitude, singlerightclick get latlng, singlerightclick google maps api, url(#default-marker) javascript, using the blue ball google maps api, ver pointer de google maps javascript, wordpress google map customize pointer, wordpress google maps move pointer, get a google map thumb pointer wordpress, put pointer on google maps, put pointer on googl emap, php google api pointers, map singlerightclick, map singlerightclick point, maps with pointers, mark a single address in google map api javascript, mark point google maps, mark point on google maps javascript, mark setinfo google maps, marker pointer on google map, mouse right click in gmap in javascript, move marker with google map api, php google map move marker, php suburb location select script, pointer on gmap, put a marker googlemaps javascript, put map with pointer on site, map pointer javascripy, add pointer to google earth, get singlerightclick latlng, gevent addlistener marker right click, gevent addlistener select location, gevent addlistener singlerightclick, gevent addlistener(marker right clickt function(), GEvent addListener(marker singlerightclick function(), gevent listener right click, gevent rightclick, gmarker rightclick, google api move pointer, google api pointer, Xhanch, Xhanch Studio


Posted on 2010-03-08 by Susanto BSc in Free Script, JavaScript
Pointer, Google Maps, Javascript, Free, Map, Script, Google, Maps, Code, Coordinate, Xhanch, Xhanch Studio

Tagged as: , , , , , , , , ,

2 Responses to “JavaScript – Google Maps With Pointer”

  1. tanvir says:

    Can i use this code commercially ?

    thank you

Leave a Reply

You must be logged in to post a comment.