Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)


#1 2011-12-14 13:17:04

naren
Member
Registered: 2011-12-14
Posts: 4

i want get latitude, longitude values when a marker is placed

i want get latitude, longitude values when a marker is placed with a info window showing address , so tat i can store the latitude and longitude values in database for further use.

Offline

Ads
(server costs 27.50€ per month)


#2 2011-12-14 13:31:24

kirk
Member
Registered: 2011-11-23
Posts: 13

Re: i want get latitude, longitude values when a marker is placed

i want to get rich smile

Lesson 1 : Say Hello

Lesson 2 : Expose your problem with your source code

Lesson 3 : Say Thank you

Lesson 4 : Wait and see

Bye

Offline

#3 2011-12-14 23:40:16

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: i want get latitude, longitude values when a marker is placed

"get latitude, longitude values when a marker is placed"

What method are you using to set marker?

not sure what the info window has to do with marker latLng in the question.

Offline

#4 2011-12-16 03:26:51

fariss49
Member
Registered: 2011-12-16
Posts: 3

Re: i want get latitude, longitude values when a marker is placed

<html>    
  <head> 
    <script type="text/javascript" src="../jquery/jquery-1.4.4.min.js"></script>        
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript" src="../gmap3.js"></script> 
    <style>
      body{
        text-align:center;
      }
      .gmap3{
        margin: 20px auto;
        border: 1px dashed #C0C0C0;
        width: 500px;
        height: 500px;
      }
    </style>
    
    <script type="text/javascript">
  var map;
  function initialize() {
  var myLatlng = new google.maps.LatLng(46.198392,6.142296);

  var myOptions = {
     zoom: 8,
     center: myLatlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP
     }
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

  var marker = new google.maps.Marker({
  draggable: true,
  position: myLatlng, 
  map: map,
  title: "Your location"
  });

  google.maps.event.addListener(marker, 'dragend', function (event) {
    document.getElementById("latbox").value = this.getPosition().lat();
    document.getElementById("lngbox").value = this.getPosition().lng();
});

}
</script> 
 
<body onLoad="initialize()">

  <div id="map_canvas" style="width:50%; height:50%"></div>

  <div id="latlong">
    <p>Latitude: <input size="20" type="text" id="latbox" name="lat" ></p>
    <p>Longitude: <input size="20" type="text" id="lngbox" name="lng" ></p>
  </div>

</body>
</html>

Offline

#5 2011-12-16 12:13:22

naren
Member
Registered: 2011-12-14
Posts: 4

Re: i want get latitude, longitude values when a marker is placed

Hello,
       
       Thanks to all who has replied to my to my post, i got the latitude and longitude values.
       
       Info window should pop up on the marker displaying address (ex. ) shown on the below code

<html>    
  <head> 
    <script type="text/javascript" src="../jquery/jquery-1.4.4.min.js"></script>        
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript" src="../gmap3.js"></script> 
    <style>
      body{
        text-align:center;
      }
      .gmap3{
        margin: 20px auto;
        border: 1px dashed #C0C0C0;
        width: 1000px;
        height: 500px;
      }
    </style>
    
    <script type="text/javascript">
      $(function(){
      
        $('#test1').gmap3(
          { action: 'addMarker',
            latLng: [13.073093,80.257222],
			
            map:{
              center: true,
              zoom: 15,
              mapTypeId: google.maps.MapTypeId.MAP
            },
            marker:{
              options:{
                draggable:true
              },
              events:{
                dragend: function(marker){
                  $(this).gmap3({
                    action:'getAddress',
                    latLng:marker.getPosition(),
                    callback:function(results){
                      var map = $(this).gmap3('get'),
                          infowindow = $(this).gmap3({action:'get', name:'infowindow'}),
                          content = results && results[1] ? results && results[1].formatted_address : 'no address';
                      if (infowindow){
                        infowindow.open(map, marker);
                        infowindow.setContent(content);
                      } else {
                        $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: content}});
                      }
                    }
                  });
                }
              }
            }
          }
          );
      });
    </script>
  <body>
    <div id="test1" class="gmap3"></div>
    drag & drop the marker to see the address
  </body>
</html>

Offline

#6 2011-12-16 12:26:39

naren
Member
Registered: 2011-12-14
Posts: 4

Re: i want get latitude, longitude values when a marker is placed

In the above displayed code i should get latitude and longitude values

Offline

#7 2011-12-16 15:37:37

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: i want get latitude, longitude values when a marker is placed

dragend:function( marker){

	var position=marker.getPosition();
	var lat=position.lat();
	var lng=position.lng();

	$(this).gmap3({
		action:'getAddress',
		latLng:[lat,lng],
		callback:function(results){
			 // parse address from results and send address, lat and lng to server with ajax here
			 
			 // the rest of your code......

Offline

#8 2011-12-17 05:45:39

naren
Member
Registered: 2011-12-14
Posts: 4

Re: i want get latitude, longitude values when a marker is placed

Hi charlietfl,
                   Very much thanks for your reply it was a huge help, got the code working.

Offline

#9 2016-03-25 05:08:33

waleeed12
Member
Registered: 2016-03-25
Posts: 1

Re: i want get latitude, longitude values when a marker is placed

what the info window has to do with marker latLng in the question.

Last edited by waleeed12 (2016-04-02 06:58:59)

Offline

#10 2017-08-26 04:08:04

ronnykinge
Member
Registered: 2017-04-06
Posts: 3,311

Re: i want get latitude, longitude values when a marker is placed

options About options trading with examples Bombay stock exchange trading. alter the and they are making their way into school systems around the country.  have you ever noticed how many things require your attention? rigid designators flank the identitysign, the resulting statement. rdon, Studi di struttura nucleare tramite coincidenze particelle carichegamma, Universit.  will pay someone to do my assignment 
The true power of a Professional PowerPoint Presentation is being able to. What is the nature of his secret? Keep in mind that she may be looking at several event.  skills for sales manager resume  django form wizard define form list and condition dict in views. 
guidelines are generally applicable, specific format and style will be dictated by.  resume format for mechanical engineer freshers  Use your paragraph comedy shortstories skills and start making money online today Freelancer is the largest marketplace for jobs in the world. a huge development for race relations during the late 1960's.

Offline

Board footer

Powered by FluxBB