jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
613 stars 68 forks source link

GoogleMap Features #174

Open jarvisteach opened 7 years ago

jarvisteach commented 7 years ago

Split out from issue #136

Version 2, should have:

Version 3, should have:

Also:

jarvisteach commented 7 years ago

For scrolling, 2 things are important:

Combining these will allow us to calculate the height & width in lat/long. Then we just add/subtract these depending on the direction, and show a new tile.

Latitude is the number of degrees north/south form the equator, up to 90 - reaching 90 hits a pole. Longitude is the number of degrees east/west from greenwich, up to 180 - reaching 180 hits the international date line.

So:

https://gis.stackexchange.com/questions/7430/what-ratio-scales-do-google-maps-zoom-levels-correspond-to

jarvisteach commented 7 years ago

Should include an image to show when can't connect to GoogleMaps.

jarvisteach commented 7 years ago

This site details how to convert an address into LAT/LONG: https://developers.google.com/maps/documentation/geocoding/intro

It requires an API key: https://developers.google.com/maps/documentation/javascript/get-api-key Giving 2,500 requests/day - should suffice.

Given two parameters: address & key, it returns something like below. With location containing the important data;

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "France",
               "short_name" : "FR",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "France",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 51.1241999,
                  "lng" : 9.6624999
               },
               "southwest" : {
                  "lat" : 41.3253001,
                  "lng" : -5.5591
               }
            },
            "location" : {
               "lat" : 46.227638,
               "lng" : 2.213749
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.1241999,
                  "lng" : 9.6624999
               },
               "southwest" : {
                  "lat" : 41.3253001,
                  "lng" : -5.5591
               }
            }
         },
         "place_id" : "ChIJMVd4MymgVA0R99lHx5Y__Ws",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}
jarvisteach commented 7 years ago

Issue at school - proxy server blocks GoogleMap request. Need to first register the proxy. Function to set a proxy string, if it's set then should use it. Should also handle proxy error, show message, and give pop-up to collect the connection string.

jarvisteach commented 6 years ago

Have got this working at school, by bypassing proxies:

urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler({})))

When a connection fails, we should look at error codes, if we get a 407, we can try the above line of code, to see if it works...