using seperate fields for lat/long with googlemapsplugin

tagger

Member
Hi,

I need to import and export tables with two seperate fields for latitude and longitude instead of the single field the googlemapsplugin requires.

Importing the table is no prob by adding (lat,long):4 field, but now i still need the javascript/php so that the two lat/long fields and the googlemaps field stay in sync.

Thank you very much for your help!
 
This is still something I'd like to add as an option on the map element, so you could specify two other elements to sync up with for lat and long.

I'd be interested in opinions on how this would need to work, with regards to how the sync'ing works. Importing from CSV would be easy to do, as the main element model already has a prepareCSVData(), which I could override in the map element, so it grabs the separate lat and long and builds the map element data from it.

The main issue is whether the "watched" lat and long fields take precedence when rendering. So if you changed those, independently of Fabrik, on existing data ... should we re-write the map element data. Or should we only do one-way sync'ing, so when you save a form, we write the new map element values to the watched fields.

-- hugh
 
Hi, thanks for your answer.
From my point of view, best would be if i could choose which way to go (single field or dual fields(lat and long) in map element settings where I can also choose the field (for single field option) or fields (for double field option).
Twoway sync should be no issue then?
regards!
 
Well, without some serious hackery on the way we handle elements, and a more or less bottom up rewrite of much of the map element code, we wouldn't be able to "choose one or the other". Fabrik elements have a one-to-one correlation with fields in the underlying table (well, except for 'repeat' elements like multiple select joins, but that's different).

The element will have to continue using the single, combined table field for normal operation. All I can do is sync, in either or both directions.

Basically this is a way to allow you to use the Fabrik map element, but:

1) Import from a CSV and sync a separate lat/long field setup into the map element.

2) Sync from the Fabrik single element to the "watched" pair of fields when the form is submitted.

3) Optionally sync from the "watched" pair to the Fabrik element when loading an existing row.

As it makes no sense to make 2) optional, as if you change the Fabrik element data, you'd obviously want to change the "watched" data. The only option is really whether we check when loading a row to edit it, to see if the "watched" fields have changed, and if so update the Fabrik element field accordingly.

-- hugh
 
It will be nice to have an embedded feature such the one Hugh described but I had to solve the same problem and I've used a calc element to split the GMAP elt into separate formated fields lat and long ready to export....
 
Okay, thanks for the answers.
I am getting a bit confused. Let me tell you my actual status: I have a table with a lat field and a long field. For use with map element, i add a 3rd "location" field with (lat,long):4 content. After that, map element works and shows me the right marker position on map. Now people gonna change that marker. Changing the location field with (lat/long):4.
Now, I guess, I just need a php/js snippet which synces the two lat long fields with the loaction field on save of the form (with the new changed location).

If somebody could tell me the code and where to put it in, I would be very thankful.
 
In my case, I set up a calc element which contains the following code (example for latitude) :

the first line retrieves the info from the regular GMAP element

In my case the result is formated as you can see in the capture.

PHP:
$lat = "{BASULM_terrains___coordonnees_raw}";
$lat = 1.0 * substr($lat,1,strpos($lat,',')-1);
$result="N ";
if ($lat < 0) $result="S ";
$lat=abs($lat);
$lat_m = $lat-intval($lat);
$lat_s = $lat_m*60-intval($lat_m*60);
$lat_d = "000".intval($lat);
$result = $result.substr($lat_d,-2);
$lat_m = "00".intval($lat_m*60);
$result = $result." ".substr($lat_m,-2);
$lat_s = "00".round($lat_s*60,0);
$result = $result." ".substr($lat_s,-2);
return $result;
 

Attachments

  • Capture.JPG
    Capture.JPG
    45.7 KB · Views: 178
  • LF4052.pdf
    523.1 KB · Views: 276
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top