2
votes

I'm trying to give a mark over a certain place in Google Map. However I feel that the marker of the Google Map is not accurate.

For example, let's try put White House using Marker in Google Map. Based on Google Earth, White House is in 38°53'51.54"N and 77° 2'8.40"W.

I convert it to latitude 38.535154 and longitude -77.2840

So I created this code:

var company = new google.maps.LatLng(38.535154,  -77.2840);
  var marker;
  var map;

  function initialize() {
    var latlng = new google.maps.LatLng(38.535154,  -77.2840);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

    marker = new google.maps.Marker({
        map:map,
        draggable:true,
        animation: google.maps.Animation.DROP,
        position: company
      });
      google.maps.event.addListener(marker, 'click', toggleBounce);

  }

However, after I open my browser, my marker is in South West of Washington. enter image description here

So my questions are :

  1. Is Google Maps latitude & longitude is a bit off ( not in sync with Google Earth ) or is there anything wrong with my conversion or my code ?

  2. If let say the Google Earth Long & Lat is the wrong one, is there a way to know longitude and latitude directly from Google Map?

2
Well, i dont know how to convert. If i know, i wont ask. - Rudy

2 Answers

10
votes

Your convertion is not right. One degree is 60 minutes and one minute is 60 seconds. So 38°53'51.54"N is 38 degrees + 53/60 + 51.54/3600 degrees. And the result is 38,89765°, not 38.535154° The same applies to the longitude.

1
votes

To answer the second part of the question: Yes there is a way to derive LatLng coordinates from Google Maps.

Open Google Maps, click the little gear icon in the upper right corner and choose "Maps Labs". Scroll down to the "LatLng Marker" and enable it and save. Back in the map do a right click on any location that you want to find the coordinates for and select "Drop LatLng Marker" from the context menu. You can even copy the coordinate values from the marker that appears: mark the coordinate text by quickly clicking three times into it, copy, paste.

Update:

To use the above technique you have to use Google Maps Classic. The NEW Google Maps that is currently (2013/11) offered as an option, does not yet contain any labs tools. If you should already have switched to the new Maps, it offers you a possibility to temporarily (or permanently) switch back to the classic version.