I have a list of GPS coordinates.E.g.

GPSList = {{47.680800, 17.626446}, {47.681078, 17.627283}, {47.682759,

I would like to crate a Google Map of the part of the city (Győr) with some signs. If I could do that, I could change simple red dots to discs or bars showing data.

Show[CountryData["Hungary", {"Shape", "Equirectangular"}], 
 Axes -> True, 
 Epilog -> {PointSize[0.01], Red, Point[Reverse /@ GPSList]}]

The resolution of that is not enough.

  • $\begingroup$ Have you seen this? $\endgroup$ – gpap Apr 22 '14 at 10:58
  • $\begingroup$ And this or this? $\endgroup$ – Öskå Apr 22 '14 at 11:10
  • 1
    $\begingroup$ Version 10 will have this built-in. $\endgroup$ – Sjoerd C. de Vries Apr 22 '14 at 11:38
  • 1
    $\begingroup$ I think the question needs to be formulated a bit more clearly and in more detail before a solid answer can be given. It sounds like you want to create (typo?) a GoogleMap using Mathematica? If so, this question is certainly not a duplicate nor does it represent functionality present in V10. Do you have an example? Perhaps, a pointer to the type of map you would like to create? $\endgroup$ – Mark McClure Apr 22 '14 at 13:08
  • $\begingroup$ Locations are inside one city, some 100 m far from each other. They are sampling points. Technically I could do printscreen on GoogleMap (appropriate part of the city), than paint the sites on it. But it would be nicer to generate it. I could use it for any field research when I use GPS device e.g. marking of presence of a particular species. Using some Mathematica generated marker instead of Google’s drop would be better, because I could resize it (e.g., proportional to abundance). $\endgroup$ – Vica Apr 22 '14 at 19:43

I guess you're hoping to take data produced by Mathematica via commands like CountryData and CityData and display that data on a map of some type. From your question, it's honestly not totally clear if you'd prefer an in notebook solution or a completely separate Google Map but both are possible.

A static map in notebook

In order to display your points as markers on a map contained right in the notebook, we can use Google's static map API. To do so, we simply construct a URL with query string based on your data and Import the result.

GPSList = {{47.680800, 17.626446}, {47.681078, 17.627283}, {47.682759, 17.631810}};
markerString[{lat_, lng_}] := "&markers=" <> ToString[lat] <> "," <> ToString[lng];
url = StringJoin[Flatten[{
   markerString /@ GPSList}]]

(* Out: "http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=800x500&zoom=16&markers=47.6808,17.6264&markers=47.6811,17.6273&markers=47.6828,17.6318" *)

enter image description here

Quite a lot more could be done with this but, mostly, this involves the static map API, as opposed to Mathematica. Also, as Sjoerd points out, the publicly available Wolfram Language documentation indicates that V10 will have some functionality very similar to this.

A standalone Google Map

Alternatively, you might want to export your data to an entirely separate Google Map using HTML and Javascript. This is a bit more complicated but still quite doable. Here's a relatively simple approach to this. Note that template, which incorporates a fair amount of HTML and Javascript that's rather irrelevant to the Mathematica side, is defined below.

coords = Map[CityData[#, "Coordinates"] &, 
    {"Asheville", "Atlanta", "Charlotte", "Knoxville"}];
{{s, n}, {w, e}} = {Min[#], Max[#]} & /@ Transpose[coords];
marker[{lat_, lng_}] := StringJoin[
"\n        new google.maps.Marker({
            position: new google.maps.LatLng(", 
            ToString[lat], ", ", ToString[lng], "), 
            map: map}
markers = StringJoin[marker /@ coords];
mapHTML = StringReplace[template,
   {"(*N*)" -> ToString[n], "(*S*)" -> ToString[s],
    "(*E*)" -> ToString[e], "(*W*)" -> ToString[w],
    "(*MARKERS*)" -> markers}];
Export["map.html", mapHTML, "Text"]

This should create a file called map.html in your current working directory. If you open it in a web browser, you should see something like so:

enter image description here

Of course, to display this on the web, you'll need a Google Maps API key, but you can open the local file and check it out right away.

Here's the definition of template:

template = "<!DOCTYPE html>
<meta name='viewport' content='initial-scale=1.0, user-scalable=no' />
<style type='text/css'>
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
<script type='text/javascript'
<script type='text/javascript'>
      function initialize() {
          var map = new google.maps.Map(document.getElementById('map-canvas'));
          var sw = new google.maps.LatLng((*S*), (*W*));
          var ne = new google.maps.LatLng((*N*), (*E*));(*MARKERS*)
          var bounds = new google.maps.LatLngBounds(sw, ne);
      google.maps.event.addDomListener(window, 'load', initialize);
    <div id='map-canvas'/>
  • 1
    $\begingroup$ This is excellent code, and easy to modify. I just modified it for Texas cities, and then did my own town. It works seamlessly. I will now be owning this. $\endgroup$ – J. W. Perry Apr 22 '14 at 17:59
  • 1
    $\begingroup$ @J.W.Perry Thanks - I'm glad you like it! $\endgroup$ – Mark McClure Apr 22 '14 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.