Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

User location: Country missing from location data?

6 years 5 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Since JomSocial uses Google Geolocation API why do users need to enter Neighborhood/City(Town)/(State)Country manually with additional fields when all those can be extracted from single geolocation query? Something like:
stackoverflow.com/questions/35145932/how...google-places-result
developers.google.com/places/web-service...laceDetailsResponses
Only needed is to add options to Location field which info we need to save. Or option to create few read only Location fields that use data from initial Location?

6 years 5 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

We have field type "location", have you tried it? with it you dont need to use city and country anymore.

thank you!

6 years 5 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

I know that location saves lat/long and city info in user profile and that is fine for most situations. But, if I need configuration like in this tutorial:
documentation.jomsocial.com/wiki/Custom_Profile_Fields
City is entered manually and Country picked from drop down list. Those are really unnecessary since both data can be picked from same location request.
Can you point me in right direction to JavaScript that handles location?
To create new field(s) we need to create 1 php and 1 xml in folder:
...\components\com_community\libraries\fields
or some other edits are needed?

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

I have figured out that myfield.php and myfield.xml are needed and I need to add those to
...\components\com_community\libraries\fields\customfields.xml
as

		<field>
			<type>myfield</type>
			<name>MyField</name>
		</field>
Found also that
...\components\com_community\libraries\services\google.php
and
...\components\com_community\controllers\location.php
probably contain the rest of the code needed for getting detailed location info for each user.
Is there something else that I'm missing?
Is there some other way to get neighborhood/city/state/country from current location field?

6 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

So do you want to create new customfield? you also need create new file xml file and php file inside folder /fields/, you can follow and copy the stucture file from text.php and text.xml

thank you!

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Not exactly. Besides myfield.php and myfield.xml modification needs to be done in
...\components\com_community\libraries\fields\customfields.xml
and add
<field>
<type>myfield</type>
<name>My Field Name</name>
</field>
Also in ..\components\com_community\libraries\core.php
there is static function autoload_libraries
that needs to be updated with new class from myfield.php
'CFieldsMyfield' => '/libraries/fields/myfield.php',

As for location, where is script that sends data to myfield.php since I need to add new values to fill new form hidden fields?

6 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

The data will be stored automatically from edit profile functions.. just make sure the code for new field is correct in function getFieldHTML(), on that function you need variable $field, that is variable object, which is the object has params, value, id of the field record.

thank you!

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

That is OK when working with standard fields. My intention is to insert additional data into location field like city, state, country besides lat, long, desc and name. There are cases that google does not return all data as formatted_address and there is much more precise data for same location in address_components. Function that fills data into location form for user is in bundle.js (0, joms.jQuery, window._, function (o, t, n) {... line 728?

6 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

I dont really undestand, please provide me the screenshot of technical issue or the video to explain it.. it will be very usefull.

thank you!

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Your script uses Google geolocation to get lat/long and address data. And it works for most cases, but in some cases Country is missing from data that is saved in field data.
Example 1 :
Type in address: Pirrama Rd Pyrmont (pick first option/suggestion)
and data will be: "name":"Pirrama Rd","desc":"Pyrmont, New South Wales, Australia","lat":"-33.8664019","lng":"151.1951044"
Which is fine.
Example 2:
Type in address: Zvezdara Belgrade (pick second option/suggestion since it is more accurate)
and data will be: "name":"Zvezdara","desc":"Belgrade","lat":"44.8033693","lng":"20.506256200000053"
"desc" part is missing country and that data does exist in google response but it is removed by your scripts. In google response for this address postal number is missing since google does not have that data.
I'm trying to implement full "formatted_address" into "desc" since it represents more accurate data IMHO.

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Basic line is: Location in JomSocial does not work for all locations on Earth as it should or consistently. For some country locations country name is missing which is not nice :) since city names are not unique.
So, for example: Zvezdara Beograd Google response is:

adr_address:
"Zvezdara 2, <span class="locality">Belgrade</span>, <span class="country-name">Serbia</span>"
formatted_address:
"Zvezdara 2, Belgrade, Serbia"
and
address_components:
Array(4)
0:long_name:
"Zvezdara 2"
short_name:
"Zvezdara 2"
types:(2) ["neighborhood", "political"]
__proto__:Object
1:long_name:
"Belgrade"
short_name:
"BG"
types:(2) ["locality", "political"]
__proto__:Object
2:long_name:
"City of Belgrade"
short_name:
"City of Belgrade"
types:(2) ["administrative_area_level_2", "political"]
__proto__:Object
3:long_name:
"Serbia"
short_name:
"RS"
types:(2) ["country", "political"]
that contains all necessary data to form valid location for JomSocial to store.
Other location like Pirrama Rd Pyrmont:
adr_address:
"<span class="street-address">Pirrama Rd</span>, <span class="locality">Pyrmont</span> <span class="region">NSW</span> <span class="postal-code">2009</span>, <span class="country-name">Australia</span>"
formatted_address:
"Pirrama Rd, Pyrmont NSW 2009, Australia"
and
address_components:
Array(5)
0:long_name:
"Pirrama Road"
short_name:
"Pirrama Rd"
types:["route"]
__proto__:Object
1:
long_name:
"Pyrmont"
short_name:
"Pyrmont"
types:(2) ["locality", "political"]
__proto__:
Object
2:long_name:
"New South Wales"
short_name:
"NSW"
types:(2) ["administrative_area_level_1", "political"]
__proto__:Object
3:long_name:
"Australia"
short_name:
"AU"
types:(2) ["country", "political"]
__proto__:Object
4:long_name:
"2009"
short_name:
"2009"
types:["postal_code"]
also has same data with postal code added. Can you look at this and provide fix? Data is from ...\components\com_community\assets\release\js\bundle.js by simply console.log (o), at (0, joms.jQuery, window._, function (o, t, n) ... after block:
		e.prototype.select = function (o) {
			var n = t(o.currentTarget),
			e = n.find(".js-name").text(),
			s = n.find(".js-desc").text(),
			i = n.data("place-id");
			o.preventDefault(),
			o.stopPropagation(),
			i && (this.$input.val(e), this.$inputDesc.val(s), this.$description.html(s), this._get_location_detail(i).done(function (o) {
					var t = o.geometry.location;
					this.$inputLat.val(t.lat()),
					this.$inputLng.val(t.lng()),

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

All locations in Republic of Serbia are missing country in location data. Haven't found more countries that are affected by this. Can you provide fix for this?

6 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Well, actaully our location data is be taken from Google Map API, and we just get the JSON data.. and we follow the data from JSON.. can you make sure the location is there if you search from google maps directly?

6 years 4 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

That is exactly the problem. Your script gets data from google and that data is OK, and contains country name. After some of your script makes changes to that data to be stored in db, country is missing.
- If user enters "Zvezdara Beograd" as location data, location is found and displayed as list of 5 places. Pick second one since it is more accurate. In db only "Zvezdara, Belgrade" will be saved without country and that data exists in google response.
- If user exters "Pirrama Road Pyrmont" as location data, location is found and also 5 options will appear, pick first one. In db will be will saved "Pyrmont, New South Wales, Australia" with country.
In both cases google responds with full data address, city and country but in first case country is missing from saved data in database. You script is removing country data when country is Serbia. I have found that error only in case of Serbia not any other country.

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW