In the Book of Mormon, Lehi and his family and others left Jerusalem for the promised land about 600 B.C. It became apparent that they needed some method to find their way. A spiritual compass became the means. In 1 Nephi 16:10, Lehi's son Nephi records that his father Lehi found in front of his tent door ..."a round ball of curious workmanship; and it was of fine brass. And within the ball were two spindles; and the one pointed the way whither we should go into the wilderness." Later in the Book of Mormon in Alma 37:38 ..."our fathers called it Liahona, which is interpreted, a compass; and the Lord prepared it." In 1 Nephi 16:16 "And we did follow the directions of the ball, which led us in the more fertile parts of the wilderness." In 1 Nephi 16: 27,29 we read "And it came to pass that when when my father beheld the things which where written upon the ball, he did fear and tremble exceedingly, and also my brethren and the sons of Ishmael and our wives." ..."And there were written upon them a new writing, which was plain to be read, which did give us understanding concerning the ways of the Lord; and it was written and changed from time to time, according to the faith and diligence which we gave unto it. And thus we see that by small means the Lord can bring about great things."
Directions of the party are mentioned in 1 Nephi 16: 13 and 1 Nephi 17:1 where they built a ship by the sea. They also, probably, used the compass on their ocean voyage to the promised land. This additional information, obtained from the Lord, was apparently of much greater use than what could have been supplied by astronomical sightings, such as the rising and setting sun, to give them a near eastern and western direction -- assuming they knew the appropriate time of year to "correct" for the sun's location above or below the path of the sun, due to the 23.5 degree tilt of the earth.
Scientifically, it is doubtful that the Liahona was a magnetic compass as we use it today. The description of the brass ball, given above, appears to be more like an instrument that is non-scientific. From early times, brass has been used as a metal which has the appearance of gold. In the time of the Olmecs in Central America, they had a magnetic compass, between 1400 to 1000 B.C., which used a polished lodestone (iron oxide--hematite) - which was magnetic and polished with a groove on one end for sighting within the earth's magnetic field. See "The Physics Book" by Clifford A. Pickover, on page 34, and published in 2011. This type of compass was a type of a magnetic compass and is not like the brass ball. When the Mormons came west to the Great Salt Lake Valley, Orson Pratt used a chronometer and a sextant to determine longitude and latitude of their location as they moved in a westerly direction which is unlike the description of the brass ball.
It is interesting that the Book of Mormon describes a compass that is somewhat scientific in nature, as a necessary means to direct Lehi and his family, and friends, rather than using astronomical observations. The other option would be to use revelation - without the help of a compass.