• Resolved Tom

    (@petrfalk007)


    problem with decimal part of lat and long numbers when working with coordinates in db and javascript, so the position shown is e.g. (50; 13) instead of (50.1545;13.934) etc.

    Maybe problem with locale (I’m using czech version of WP) or there is an error in coordinates computing.

    In database the coords are saved with decimal points but some are with decimal point as “,” and some with “.” – I don’t know what changed this, happend in the process of theming site (some content with positions was already created – the old posts were saved in db with “.” as decimal point – when shown, these were translated in geotag for JS to “,” which google js cannot recognize – position lost)

    While new posts are saved in db with decimal point as “,” and then when edited the decimal part of nuber is lost as well when handed over to google js – just whole part of nuber is sent as coords – so the position is lost again..

    Probably problem with locale setting.

Viewing 1 replies (of 1 total)
  • Thread Starter Tom

    (@petrfalk007)

    Finaly found the solution:

    simple as that – php floatval function is dangerous with specific locales

    Solution:

    add these lines into geotag.php

    // help with floatval php function problem with locale
    
    function floatval_safe($value)
    {
        $value = floatval($value);
        $larr = localeconv();
        $search = array(
            $larr['decimal_point'],
            $larr['mon_decimal_point'],
            $larr['thousands_sep'],
            $larr['mon_thousands_sep'],
            //$larr['currency_symbol'],
            //$larr['int_curr_symbol']
        );
        //$replace = array('.', '.', '', '', '', '');
        $replace = array('.', '.', '', '');
    
        return str_replace($search, $replace, $value);
    }

    and replace all occurences of floatval with new function floatval_safe

Viewing 1 replies (of 1 total)
  • The topic ‘Geotag plugin – map coordinates not displayed correctly – bad position’ is closed to new replies.