Python Flask-GoogleMaps where to change default region? - python

I am using flask google maps to display a google map.
I noticed that the default preferenced region is USA and that it can be changed in script. I need the region to be germany:
When you load the Google Maps JavaScript API from maps.googleapis.com it applies a default bias for application behavior towards the United States. If you want to alter your application to serve different map tiles or bias the application (such as biasing geocoding results towards the region), you can override this default behavior by adding a region parameter to the tag when loading the Maps JavaScript API code.
This needs to be changed because there are cities with the same name and for example the input "Potsdam" shows a city in the USA instead the city in germany.
As far as I understand the region argument has to be added here, my map in python:
mymap = Map(
identifier="view-side",
lat=location.latitude,
lng=location.longitude,
infobox=[],
markers=[],
zoom = 11
)
I tried to add region = "Germany" but nothing happened.
There is no example in the documentation.

Flask-GoogleMaps should be just a wrapper around the Google Maps API.
The location documentation from the google maps api states:
Language localization
By default, the Google Maps JavaScript API uses the user's preferred
language setting as specified in the browser, when displaying textual
information such as the names for controls, copyright notices, driving
directions and labels on maps. In most cases, it's preferable to
respect the browser setting. However, if you want the Maps JavaScript
API to ignore the browser's language setting, you can force it to
display information in a particular language by adding a language
parameter to the tag when loading the Maps JavaScript API
code.
The following example displays a map in Japanese and sets the region
to Japan:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=ja&region=JP">
So you could define the region in the javascript script tag where you load the google libary in your template.
A google region code is a IANA language region subtag
According to this page the region code for Germany should be DE

Sadly adding the ?region=DE argument to the script did not work aswell, so I managed to solve it with a trick.
I simply added germany "Deutschland" to the location which the user searches.
Solution:
location = geolocator.geocode("Deutschland, " + findroomcity)

Currently it seems googlemaps API do not provide the feature that you require.
But, in my opinion you should include country/region name in the search query so that it returns correct result. Correct search query (eg. Potsdam, Germany) is the solution here

Related

API to get all pincodes inside a radius

I'm working on a python application where we need to get all the pincodes within a specific radius.
We have a base location and a radius of 10Km is drawn from this base pincode.
Do we have any API where this can be achieved?
FYA - Mainly looking for Indian PostalCodes.
First thing that comes to my mind is the Google Maps API, under this link you can find the relevant guide for it: https://developers.google.com/maps/web-services/client-library
I guess that you will need to sign up for google maps api key and enable the place search feature for your key. I think this Place Search feature is all you need for your task.

Django : How to get longitude and latitude from google maps user selected adress and save to database

I am new to Django and Python.
I want to make a view in which user can open the google maps ( or anything similar), choose a location (put a thumbtack) on map and get the longitude and latitude from this location to save to database.
I searched the internet but i am confused about how to do it
Can you please , guide me where to look or what to use?
Many thanks for spending your time to help me
Kostas
Google has an API key to access google-map
api_key = "Your private key for google map here"
address="address of the selected user"
api_response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address={0}&key={1}'.format(address, api_key))
api_response_dict = api_response.json()
this will search the address on the map and give you a response back to the 'api_response' variable
from this variable you can access the longitude and lattitude of the address given above
api_response_dict = api_response.json() # this line used to covert the response into a dict format/json format
latitude = api_response_dict['results'][0]['geometry']['location']['lat']
longitude = api_response_dict['results'][0]['geometry']['location']['lng']
The Bing Maps APIs include map controls and services that you can use to incorporate Bing Maps in applications and websites. In addition to interactive and static maps, the APIs provide access to other geospatial features such as geocoding, route and traffic data and spatial data sources that you can use to store and query data that has a spatial component, such as store locations.
Step 1: Create a Bing Maps Key
Step 2: Run Python Script
Source : http://helpdoc.info/how-to-get-latitude-longitude-by-using-address-from-bing-api/

How to obtain google map images "satellite view without labels" using python

I know about Google map static API which can return map as an image. But it returns static view and I need satellite view of google map without labels for my system. I've been searching for solution for so long but couldn't find any.
any help would really be appreciated.
If your intention is to get static maps satellite imagery via official service and hide all labels on it (except Google logo and copyrights) you can set map type to satellite and apply styles that hide all labels with Static Maps API. For example,
https://maps.googleapis.com/maps/api/staticmap?center=39.279117%2C-89.881745&zoom=18&size=600x400&maptype=satellite&style=feature%3Aall%7Celement%3Alabels%7Cvisibility%3Aoff&key=YOUR_API_KEY
Otherwise if you want download and store images for your needs, stitch them or remove copyright labels the solution might be not compliant with Google Maps API Terms of Service.
Look at the following sections of Terms of Service.
Paragraph 10.1 (a)
No access to APIs or Content except through the Service. You will not access the Maps API(s) or the Content except through the Service. For example, you must not access map tiles or imagery through interfaces or channels (including undocumented Google interfaces) other than the Maps API(s).
That means you cannot scrap satellite imagery for your needs and store it in your storage.
Paragraph 10.5 (g)
No removing, obscuring, or altering terms of service, links, or proprietary rights notices. You will not:
remove, obscure, or alter any Google terms of service or any links to or notices of those terms, or any copyright, trademark, or other proprietary rights notices; or
falsify or delete any author attributions, legal notices, or other labels of the origin or source of material.
Finally, paragraph 10.5 (b)
No derivative works. You will not modify or create a derivative work based on any Content unless expressly permitted to do so under these Terms. For example, the following are prohibited: (i) creating server-side modification of map tiles; (ii) stitching multiple static map images together to display a map that is larger than permitted in the Maps APIs Documentation; or (iii) tracing or copying the copyrightable elements of Google’s maps or building outlines and creating a new work, such as a new mapping or navigation dataset.
I hope my answer addresses your question.

Getting information of a panoram in google street view python

I'm using the following url to get important information of one latitud-longitud coordinate points in google street view.
http://maps.google.com/cbk?output=xml&ll=....
Specifically I need to know what is the real coordinates for google street view for a GIVEN pair of coordinates.
In the Python API there is not how to access to this information.
For example:
http://maps.google.com/cbk?output=xml&ll=46.414382,10.013988
For the (latitud,longitud)=(46.414382,10.013988)
This is the only way I found to do it in Python.
My question is, is it legal to use this url to get this information?
Thank you so much
From the Google Maps API TOS: 10.4d
No use of Content without a Google map. Unless the Maps APIs Documentation expressly permits you to do so, you will not use the Content in a Maps API Implementation without a corresponding Google map. For example, you may display Street View imagery without a corresponding Google map because the Maps APIs Documentation expressly permits this use.
I'm not sure if the endpoint you mention is explicitly documented and use without a map is allowed somewhere in the API docs, if not, I think 10.4d applies and you are not allowed to use it.

It's possible to validate/lint/bleach a piece of code given by analytics/tracking sites like Google Analytics or Piwik

I provide in the administration interface of the site I make an area for the webmaster to place tracking codes from external analytic tools. Essentially, this codes must be included 'as-is', but my concern is that any typo could render the page useless, mess-up the HTML, etc...
It's possible (at some extent) to cleanup/validate these codes so I least it ensures the HTML won't be corrupted?
I'm using Python/Django, but i guess the Django part is somewhat irrelevant for this topic.
Regards
The easy way would be to grab the code from the tracking site and hard-code everything but the unique portion (usually a user ID number), offer the user a choice of approved trackers (with a radio button) and have them paste in their ID, then insert that value when you render the page. If I remember correctly, blogger worked like this before they tied it in directly with analytics via the google account.

Categories

Resources