Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello all...
i want to show latitude and longitude of particular place on google map...
mean when i click on place A ,latitude and longitude will be shown in infoWindow...
and when i click on place B ,latitude and longitude will be shown in infoWindow...
plz help me...how i can do this...

Thnks for help !!!!
Posted

Try..

XML
<html>
<head>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
 <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript">

  var  geocoder = new google.maps.Geocoder();
 var infowindow = new google.maps.InfoWindow();
var latlang=new google.maps.LatLng(geoip_latitude(), geoip_longitude());
  function initialize()
  {
      var myOptions = {
      center: latlang,
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP

    };
    var map = new google.maps.Map(document.getElementById("map"), myOptions);
 geocoder.geocode({ 'latLng': latlang }, function (items, status) {

                    if (status == google.maps.GeocoderStatus.OK) {

                        map.setZoom(8);

                       var marker = new google.maps.Marker({
                            position: latlang ,
                            map: map
                        });

                     infowindow.setContent(items[1].formatted_address);
                         google.maps.event.addListener(marker, 'click', function () {


                infowindow.open(map, this);
                map.setZoom(8);
            });
                    }

                });
google.maps.event.addListener(map, 'click', function (event) {

                geocoder.geocode({ 'latLng': event.latLng }, function (items, status) {

                    if (status == google.maps.GeocoderStatus.OK) {
                        $('#latitude').val(items[0].geometry.location.lat().toString().substr(0, 12));
                        $('#longitude').val(items[0].geometry.location.lng().toString().substr(0, 12));
                        map.setZoom(8);
                       marker = new google.maps.Marker({
                            position: event.latLng,
                            map: map
                        });

                        var ll=event.latLng;
                        infowindow.setContent(ll.toString());
                        infowindow.open(map, marker);

                    }

                });
            });
}


window.onload=initialize;

</script>
</head>
<body>
<div id="map" align="center" style="height: 420px;  width:500px; top:0px; border: 1px solid black;"></div>
</body>
</html>
 
Share this answer
 
Comments
Member 9332883 20-Oct-12 22:44pm    
but how to show direction among that points ????

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900