How can I adapt the default map on the website "Contact Us" page, when I do not have an available address because it is in the middle of the woods, but I do have geographical latitude and longitude and I have also defined a Google Place.
This is the Google Place: Holzschopf
Using the Google Place or using longitude and latitude, I can create an Odoo-URL for the map thumbnail by replacing the address in the original Odoo Map URL with the Google Place name like this:
http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=8¢er=Holzschopf&key=....someGoogleAPIkey
or
http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=8¢er="47.1922423,8.5496122"&key=....someGoogleAPIkey&size=298x298
which renders the proper map thumbnail:
The thumbnail should then properly link to Google Maps:
https://www.google.com/maps/@47.1922423,8.5496122,15z/data=!4m5!3m4!1s0x479aabc19038c111:0x2bb45170352f9940!8m2!3d47.1922423!4d8.5583669
instead of
https://www.google.com/maps/search/H%C3%B6llwald,+Baar+6340,+Switzerland/@37.0625,-95.677068,4z
Can somebody give me a hint on how to create a small module which replaces the partner address by the corresponding fields partner_longitude and partner_latitude?
Hi,
I think you are refer to the google map link opened in contact us page.
if so you need to change method 'google_map_link' in /addons/website/models/res_partner.py
I just tried it in original code
@api.multi
def google_map_link(self, zoom=10):
# params = {
# 'q': '%s, %s %s, %s' % (self.street or '', self.city or '', self.zip or '', self.country_id and self.country_id.name_get()[0][1] or ''),
# 'z': zoom,
# }
params = {
'q': '%s' % ('47.1922423,8.5496122'),
'z': zoom,
}
return urlplus('https://maps.google.com/maps', params)
You can create a new module inheriting res.partner
Thanks Mohammed, this is exactly what I was looking for. How would this code look like when I would want to replace the explicit coordinates by the values of the fields partner_longitude and partner_latitude?
Could it be like this:
params = {
'q': '%s' % (self.partner_longitude,self.partner_latitude),
'z': zoom,
}
I would then make these fields editable in the module geo_localize, so these values can be manually entered when the localization based on the address does not work.
It will look like this
'q': '%s,%s' % (self.partner_longitude,self.partner_latitude),
You have to create fields partner_longitude and partner_latitude in res.partner because self refers to res.partner here
OK, understood. The fields already exists because they are created when installing the module base_geolocalize. Thank you very much! I tried to convert your comment to an answer, but it is not possible, because of your original answer. So I will edit your original answer and upvote it.
Are my edits correct like that?