-1

I have different locations to show on separate maps. Here are some examples of latitudes and longitudes I have:

"latitude" : "49 29.219N", "longitude" : "000 11.042E"

"latitude" : "49 27.264N","longitude" : "000 10.305E"

"latitude" : "49 28.456N", "longitude" : "000 09.977E"

As it seems that this format is unacceptable for Google Maps API, how can I change them to an acceptable format to mark on the map using Javascript or Ruby?

Aboozar Rajabi
  • 1,683
  • 21
  • 26
  • Does Google Maps API have anything to manage it? – Aboozar Rajabi Sep 22 '17 at 15:15
  • possible duplicate of [Google Map longitude and latitude](https://stackoverflow.com/questions/7705678/google-map-longitude-and-latitude) – geocodezip Sep 22 '17 at 15:15
  • related question: [how to convert between degrees, minutes, seconds to Decimal coordinates](https://stackoverflow.com/questions/8263959/how-to-convert-between-degrees-minutes-seconds-to-decimal-coordinates) – geocodezip Sep 22 '17 at 15:16
  • Duplicate, answered here: Converting latitude and longitude to decimal values (https://stackoverflow.com/questions/1140189/converting-latitude-and-longitude-to-decimal-values) – ronenmiller Sep 22 '17 at 15:39
  • @geocodezip Thanks for your help buy the format I have is a little bit different. I will post the solution later for the others. – Aboozar Rajabi Sep 25 '17 at 08:37
  • @ronenmiller Thanks, the same as my previous comment – Aboozar Rajabi Sep 25 '17 at 08:38

1 Answers1

0

That worked for me in an old version of Google Maps API

var myLatlng = new google.maps.LatLng(hotspot.lat,hotspot.long);

var marker = new google.maps.Marker({
        position: myLatlng,
        map: TAWI.map,
        title: hotspot.name,
        icon: TAWI.pin.normal
});

being:

  • hotspot.lat the lattitude of the marker in decimal format,
  • hotspot.long the longitude of the marker in decimal format,
  • hotspot.name the name of the marker,
  • TAWI.pin.normal a custom icon to show and
  • TAWI.map the Google Maps rendered on the page

You should check the current documentation https://developers.google.com/maps/documentation/javascript/markers

And this would help converting from one notation to the other https://grasswiki.osgeo.org/wiki/Convert_degree

jmtalarn
  • 1,513
  • 1
  • 13
  • 16