I was so frustrated during one project where I need to find out the geological latitude and longitude of the place, with the help of Google Maps. So I googled a lot and came up with a function function (overlay,point).On calling this function on mouse click event the latitude and longitude are returned as point.lat() for latitude and point.lng() for longitude. This is the source code just the javascript part.
[UPDATE DEMO]
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAPHLcOOGHX2-uLk3K8q1nMRTkUAbhgKwL1jWWfpv-KGJeCrct7hTsLLnZdnZjzehmRIkaePagQvKNbw" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 4);
var marker = new GMarker(new GLatLng(37.4419, -122.1419), {draggable: false});
map.addOverlay(marker);
GEvent.addListener(map, 'click', function(overlay, point) {
var lati=point.lat();
var long=point.lng();
var marker= new GMarker(new GLatLng(lati, long),{draggable: false});
map.addOverlay(marker);
marker.openInfoWindowHtml("Latitude:"+lati+"<br />"+"Longitude:"+long);
});
//]]>
</script>
What I have done here is I have displayed the latitude and longitude on a information window of a GMarker. GMarker represents a point on the map. I may put something about GMarker later on.
Hi! How this geo information helps me?
If You want to show the location of your system user plotted over Gmap, then you should ask the user to register their Latitude and Longitude and save it in the database.. so you need this right!
Good…It might be helpful…. We had to similar sort of thing during our travel-xp project…I think we did it using name of the country….passing it to some function…But we had not posted as u did.
This might be good reference all wanting to do that!!!:)
I think you did not get the point here. It actually shows the latitude and longitude upto 12 decimal digits (i think)of any point on the globe not only one lat and lng of a country.
Hey this is good information. I will sure use it if required in my projects. nice work.
It will be helpful to other , if you post with the ready to use source code.
good tutorial man…
@sanjeeb,
If you’d like to have a ready to use source code…then copy.. the code of first post
http://subesh.com.np/2008/05/google-map-with-zoom-and-map-type/
and replace its script with this script you will see the working demo. I will be aware now on to post a ready to use code..:D
ummm.. done a great job.. keep it up..stand still … push more harder.. heheh dont take the other way
There are some classes to auto calculate the latitude and longitude based on city, state, zipcode and country. It will be better if we can auto calculate the latitude and longitude first and show them the option to change the latitude and longitude with marker. you can get the class here: http://www.phpclasses.org/browse/package/3827.html
@yalamber,
thanks for the comment… i will look forward to it…
good work man…. sharing ideas. It’s quiet an informative one. it rooted at least some knowledge about embeding google maps in a web page to me.
hope to get more tips on the google maps from you man……
Great work. Keep it up.
Hi
I m working on the project which locates ip address on map using google
which is known to u.will u plz tell me how to retrieve data abt ip address like lat. long. and other information.
thank u for abv useful information
@tarang,
.. Feel Free to ask any other help required!
Please Download the Demo script. for From Here and go through it… I think that will be your project accomplished.
thanks man! i finally understand