Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2008, 07:34 AM
Authorized User
 
Join Date: Mar 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default google map clicked coordinates

hi friends

how can i find the coordinate if a site visitor clicked my google map?

below is my code for the gmap

thanks


<script src="http://maps.google.com/maps?file=api&key=ABQIAAAA0BO2Ps4DbLymjxuBgZcbgkPN hnwAuBgZcbgkPNhnwAa0Zz7fHWiJUQ" type="text/javascript"></script>
<div id="map" style="width: 300px; height: 300px;"></div>
                
<script type="text/javascript">
infoWinHtml="hello world";
function loadGMap()
    {
    var map = new GMap(document.getElementById("map"));
    var point = new GPoint(55.176429748535156, 25.104875594635896);
    var marker = new GMarker(point);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.centerAndZoom(point, 8);

    GEvent.addListener(marker, "click", function()
        {
        marker.openInfoWindowHtml(infoWinHtml);
        //alert("You clicked on" + GEvent. )
        });
    map.addOverlay(marker);
    }
window.onload=loadGMap;

</script>
 
Old June 16th, 2008, 01:44 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Start here:
http://code.google.com/apis/maps/doc...ion/index.html

In the section titled "Audience", click on "Map Events".

On the page that comes up, click on "Event Listeners".

Read.

Pay special attention to the section titled "Using Passed Arguments in Events".

See also this page:
http://code.google.com/apis/maps/doc...ml#Events_GMap
and notice what is passed to your function via a click event.

If you can't get it from these docs, ask again.
 
Old June 17th, 2008, 07:31 AM
Authorized User
 
Join Date: Mar 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you dear

the parameters are overlay and point, and i could say point.x and point.y

i just wanted to put a new marker on the clicked position and store the coordinates in the database.





 
Old June 17th, 2008, 12:29 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

So did it work??

Or are you still asking how?

I think you are saying it now works, yes?
 
Old June 18th, 2008, 07:32 AM
Authorized User
 
Join Date: Mar 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes, that was what i wanted and it worked.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Google Map API Markers msnyder0 Pro PHP 0 October 21st, 2008 07:22 AM
Heat Map over Google Map ajit Javascript 0 March 7th, 2008 09:01 AM
google map GetDirections problem mrjoka Javascript How-To 0 October 4th, 2007 09:08 AM
Map Coordinates dragondayz VB How-To 2 May 8th, 2006 10:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.