Results 1 to 2 of 2
  1. #1
    lilybluecat
    lilybluecat is offline
    Guest
    Join Date
    2013 Jan
    Posts
    3
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0

    How to use Google Map API for Maker Lat and Long

    How to use Google Map API for Maker Lat and Long!!

    1st you need to put this code in to your page

    Code:
    <script type="text/javascript" src=""></script> 
    <script type="text/javascript"> 
    
          var map = null;
          var marker = null;
          var defaultLat = 13.75072;
          var defaultLng = 100.61004;
          var infowindow = new google.maps.InfoWindow(
          {  
               size: new google.maps.Size(150,50)
           });
    
    
    function createMarker(latlng, name, html) {
    
        var contentString = html;
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            zIndex: Math.round(latlng.lat()*-100000)<<5
            });
    
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.setContent(contentString); 
            infowindow.open(map,marker);
            });
        google.maps.event.trigger(marker, 'click');    
        return marker;
    }
    
     
    
    function initialize() {
      // create the map
      var myOptions = {
        zoom: 10,
        center: new google.maps.LatLng(defaultLat,defaultLng),
        mapTypeControl: true,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"),
                                    myOptions);
     
      google.maps.event.addListener(map, 'click', function() {
            infowindow.close();
            });
    
      google.maps.event.addListener(map, 'click', function(event) {
    	//call function to create marker
             if (marker) {
                marker.setMap(null);
                marker = null;
             }
    	 marker = createMarker(event.latLng, "name", "<b>Location</b><br>"+event.latLng);
      });
    
    }
    </script>
    in scr="" put this with "http"+"://"+"maps.google.com/maps/api/js?sensor=false"


    2nd In BODY tag put even onload and call initialize() function

    HTML Code:
    <body onload="initialize()">
    3rd put this map object where do you want to place it

    HTML Code:
    <div id="map_canvas" style="width: 600px; height: 450px;"></div>
    Finish so easy right?

    if you want to get lat and long to insert into your database latlng

    use js script like this with variable latlng

    latlng.lat() or latlng.lng()

    Thanks for reading. Sorry for bad english. I hope you dont mind.

    Any question post it!! I'll answer as soon as possible.

  2. The Following User Says Thank You to lilybluecat For This Useful Post:


  3. #2
    Garoet
    Garoet is offline
    Guest
    Join Date
    2013 Dec
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    Hei thx for the tutorial

    Dou you know how to use google api for distance ? i need one distance nearest (i don't need alternative distance nearest)

Similar Threads

  1. [Tutorial] How to protect Rpg Maker [XP/VX/VXA] before Cheat Engine
    By Narzew in forum Anti-Cheat Systems
    Replies: 0
    Last Post: 2013-01-07, 11:16 AM
  2. Replies: 5
    Last Post: 2012-02-17, 04:06 PM
  3. Having a Long Pet name
    By ronmacam in forum Battle of the Immortals
    Replies: 0
    Last Post: 2011-05-03, 03:12 AM
  4. Agbot Script Maker
    By kazaam00nix in forum Silkroad Online
    Replies: 2
    Last Post: 2010-11-25, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •