Support » Plugin: OSM - OpenStreetMap » Suggestion: add default values for maps in settings

  • Resolved alm06130


    Was bored to adjust map position each time: modify default values in osm-config.php, but overwritten by updates-> I suggest some modifications:

    in osm-config.php:

    define ("OSM_default_lat",  apply_filters('get_osm_default_lat', get_option("osm_default_lat",43.758629))); 
    define ("OSM_default_lon",  apply_filters('get_osm_default_lon', get_option("osm_default_lon",6.924225)));
    define ("OSM_default_zoom", apply_filters('get_osm_default_zoom', get_option("osm_default_zoom",11)));

    This permits to adjust default position and zoom from wp options, filtered if needed.

    In osm-options.php (some corrections, missing form tag, sanitized values):

    <form method="post">   
     <tr> <h3>  PHP Interface setting:</h3> </tr>
      <td><label for="osm_zoom_level"><?php _e('Map Zoomlevel for the PHP Link (1-17)','OSM') ?>:</label></td>
      <td><input type="text" name="osm_zoom_level" value="<?php echo esc_attr($osm_zoom_level) ?>" /></td>
      <td><label for="osm_zoom_level"><?php _e('Default Latitude for maps','OSM') ?>:</label></td>
      <td><input type="text" name="osm_default_lat" value="<?php echo esc_attr($osm_default_lat) ?>" /></td>
      <td><label for="osm_zoom_level"><?php _e('Default Longitude for maps','OSM') ?>:</label></td>
      <td><input type="text" name="osm_default_lon" value="<?php echo esc_attr($osm_default_lon) ?>" /></td>
      <td><label for="osm_zoom_level"><?php _e('Default Zoom Level for maps','OSM') ?>:</label></td>
      <td><input type="text" name="osm_default_zoom" value="<?php echo esc_attr($osm_default_zoom) ?>" /></td>
    <div class="submit"><input type="submit" name="Options" value="<?php _e('Update Options','OSM') ?> &raquo;" /></div>

    This display form with settings for lon, lat, and zoom

    In osm.php, function option_page_osm:

      static function options_page_osm()
        // 0 = no error;
        // 1 = error occured
        $Option_Error = 0;
          // get the zoomlevel for the external link
          // and inform the user if the level was out of range
          // update_option('osm_custom_field',$_POST['osm_custom_field']);
          if ($_POST['osm_zoom_level'] >= ZOOM_LEVEL_MIN && $_POST['osm_zoom_level'] <= ZOOM_LEVEL_MAX){
          else {
            $Option_Error = 1;
            Osm::traceText(DEBUG_ERROR, "e_zoomlevel_range");
    	  //add_option('osm_custom_field', 0);
    	  add_option('osm_zoom_level', 0);
        // name of the custom field to store Long and Lat
        // for the geodata of the post
        $osm_custom_field  = get_option('osm_custom_field','OSM_geo_data');
        // zoomlevel for the link the OSM page
        $osm_zoom_level    = get_option('osm_zoom_level','7');
        //default map values 
        // update default maps values
        if (isset($_POST['osm_default_lat'])) {
            $temp_lat=(float) $_POST['osm_default_lat'];
            if ($temp_lat>LAT_MAX || $temp_lat<LAT_MIN) {
              $Option_Error = 1;
              Osm::traceText(DEBUG_ERROR, "e_default_lat_range");   
            } else {
        if (isset($_POST['osm_default_lon'])) {
            $temp_lon=(float) $_POST['osm_default_lon'];
            if ($temp_lon>LON_MAX || $temp_lon<LON_MIN) {
              $Option_Error = 1;
              Osm::traceText(DEBUG_ERROR, "e_default_lon_range");   
            } else {
        if (isset($_POST['osm_default_zoom'])) {
            $temp_zoom=(int) $_POST['osm_default_zoom'];
            if ($temp_zoom>19 || $temp_zoom<1) {
              $Option_Error = 1;
              Osm::traceText(DEBUG_ERROR, "e_default_zoom_range");   
            } else {
         // Let the user know whether all was fine or not
         if ($Option_Error  == 0){
            Osm::traceText(DEBUG_INFO, "i_options_updated");
         else {
            Osm::traceText(DEBUG_ERROR, "e_options_not_updated");

    This validate form submit

    Hope this can help

    Thanks again for this plugin

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author photoweblog


    Hello alain,

    We will consider it at the next update.

    Br, MiKa

    Plugin Author photoweblog


    We put it in the last version – thanks for your work!!!
    Br, MiKa
    BTW: Rating is welcome as well 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.