Question

i have list of coordinates that i taken from regular gps that we use in car. This coordinates when i put in google maps code with javascript don't work. What am i doing wrong here. Do i need to do any conversion !!!

var mapProp = {
      center:new google.maps.LatLng(N42°44.8437', W074°10.751'),
        zoom:16,
      mapTypeId:google.maps.MapTypeId.ROADMAP
      };
            var map=new    google.maps.Map(document.getElementById("googleMap"),mapProp);
    });
Was it helpful?

Solution

the LatLng function expects both arguments to be a number:

new google.maps.LatLng(-34.397, 150.644)

So yes, you do need to do a conversion first. Check the documentation:

  • Latitude ranges between -90 and 90 degrees, inclusive. Values above or below this range will be clamped to the nearest value within this range. For example, specifying a latitude of 100 will set the value to 90.
  • Longitude ranges between -180 and 180 degrees, inclusive. Values above or below this range will be wrapped such that they fall within the range [-180, 180). For example, 480, 840 and 1200 will all be wrapped to 120 degrees.

and see this sample

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top