Map Region Initial position and zoom not working in Oracle APEX

Viewed 372

I'm setting the default map zoom via the 'Initial Position and Zoom' configuration in the Attributes tab on the Region configuration panel with the following code:

    select to_number(:P17_GPS_LATITUDE) as LAT,
    to_number(:P17_GPS_LONGITUDE) as LON,
    15 as ZOOM
    from DUAL

This is working correctly the first time, but stops working when I enter this page again until I log off the application and log in again.
I've looked at what could be the problem and found that a part of the script that loads the map is different the first time compared to when it loads after that. The first time it loads this is what I can find (I'm only leaving the parts that are different between loads):

    apex.jQuery('#localitzacioMapa_map_region')
    .spatialMap({ 
        "regionStaticId": "localitzacioMapa", 
        "resetMapPosition": true, 
        "initPosition": { "basedOnFeatures": false, "lon": 1.8246315941379123, "lat": 45.97590926950204, "zoom": 15, "getFromBrowser": false }
    })

After that, it will load like the following code and it won't be fixed until i log off and log in again:

    apex.jQuery('#localitzacioMapa_map_region')
    .spatialMap({ 
        "regionStaticId": "localitzacioMapa", 
        "initPosition": { "basedOnFeatures": false, "zoom": 0, "getFromBrowser": false }
    })

My issue is that the LAT and LON values are not being passed correctly and the zoom value resets to 0 for some reason.

1 Answers

It looks like your items P17_GPS_LATITUDE and P17_GPS_LONGITUDE are not set to your default values correctly. Note that the default entry in the item attributes only sets the client-side default and is probably useless in your case. You need to set up the source entry correctly.

Now you should know that it is important to know, when APEX calculates something. Depending on the position of your items, it could happen that for a fresh session, where your items are initially empty, first your map gets rendered and then your items are set to the default values.

To be absolutely sure that your items have the correct default value, when the map gets rendered, use a Before Header process to check if your items are null, and then set them, like this:

enter image description here

Related