Forum

Store geolocalizati...
 
Notifications
Clear all

Store geolocalization variables (PLEASE HELP!!)

6 Posts
3 Users
0 Likes
318 Views
(@paolo)
Posts: 3
New Member
Topic starter
 

Hello everyone :)...I'm new to this amazing program and i'm trying to implement it on my server.Thanks in advance to people who read this and sorry for my bad english 😉
I'm trying to find a way to store geolocalization variables (lat and long) in osclass database.
I want to store lat and long in database table oc_t_item_location in which two geolocalization fields (d_coord lat and d_coord long) are already placed (maybe for geoloc plugins). So i was trying to create a plugin for this. Any suggestion would be appreciated. Thanks a lot!*

 
Posted : 15/04/2020 2:55 pm
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

You want to save coordinates in the two columns (d_coord lat & d_coord long)?
Where you get the values for them? When do you want to save them?

Available for custom Osclass development. www.defected.dev

 
Posted : 18/04/2020 3:41 am
(@paolo)
Posts: 3
New Member
Topic starter
 

Hello, thank you for reply!
I want to add coordinates of every item in the item-post form. Here my code:
function initAutocomplete() {
var address = 'address';
$(document).ready(function () {
    var autocomplete;
    autocomplete = new google.maps.places.Autocomplete(document.getElementById(address), {
        types: ['address'],
    });
    autocomplete.setFields(['address_component', 'geometry']);
    autocomplete.addListener('place_changed', geolocate);
function geolocate(){
    var place = autocomplete.getPlace();

    lat = place.geometry.location.lat(),
    long = place.geometry.location.lng();
-------------
(item-post.php)
<div class="control-group">
                                <label class="control-label" for="lat"><?php _e('lat', 'bender'); ?></label>
                                <div class="controls">
                                    <input id="lat" type="hidden" name="lat" value="lat" />
It works (i checked POST data with chrome). But don't save in database (still returns NULL in d_coord_lat). I don't know how to use ajax here (i guess..). 

 
Posted : 18/04/2020 1:12 pm
(@rusnam)
Posts: 219
Estimable Member
 

you need to use item_post hook to save in to database. but I don't know how exactly.

find out the hooks here https://market.osclasscommunity.com/docs/hooks

 
Posted : 19/04/2020 8:36 am
Defected
(@dftd)
Posts: 614
Honorable Member Admin
 

[member=184]Paolo[/member] You are a bit lucky in this case because Osclass already checks for lat & long fields on item post and saves them if they are present.

Just rename your hidden input names to d_coord_lat & d_coord_long.

Available for custom Osclass development. www.defected.dev

 
Posted : 04/05/2020 4:42 pm
(@paolo)
Posts: 3
New Member
Topic starter
 

Hey! thanks for reply! Unfortunately I can't make it works. Here my code:
(in item-post)

<div class="control-group">
<label class="control-label" for="d_coord_lat"><?php _e('d_coord_lat', 'bender'); ?></label>
<div class="controls">
<input id="d_coord_lat" type="hidden" name="d_coord_lat" value="12.34567890" />
</div>

This is just a test...I can see 12.34567890 in google chrome POST data sent to index.php, but on mariadb d_coord_lat is still NULL.

 
Posted : 14/05/2020 1:12 pm
Share: