To add to Pieter Geerkens great answer, another forerunner to modern military mapping is of course the Roy Military Survey of Scotland produced from 1747 to 1755. The whole map is available online.
This map was produced by Hanoverian troops during the occupation of the Highlands in it's wars against the Jacobite's. During the Jacobite uprising of 1745, the British military realised that much of Scotland was totally unknown. Maps were incomplete or centuries out of date, pieced together from interviews with people rather than an on the ground survey with modern engineering equipment. Without maps, they found that those with arrest warrants could escape into the hills and slip away down glens and lochs and out to sea.
Scotland's landmass was utterly impassible to outsiders at the time. Even today, the most Northern city in the UK is 120 miles from the north coast and the entire North West Coast is a rugged wilderness.
So to answer your supplementary question, one way to map a foreign land was to occupy it and then send a team of engineers to survey it for a decade..
This early map was a precursor to the now famous Ordnance Survey maps of the UK used by everyone from town planners to hikers.
More generally, the Roy map is a landmark of cartography, exemplifying
emerging standards in military surveying and cartography. It held a
seminal influence on British military mapping in the later 18th
century, and, not least through its chief surveyor William Roy, had a
crucial influence on the early work of the Ordnance Survey itself.
- Map of a Nation by Rachel Hewitt