Initial layout cannot display a MAP

Opening my applycation I would like to see
a map … so I added geoMap object to the main-view.xml .

I can see Avatar and Button
Cannot dispaly a map
Is there an example I can read ?

Do I miss something ?

    <initialLayout>

            <avatar/>
            <button text="aaaa"/>

        <maps:geoMap id="map"
                     height="400px"
                     width="800px"
                     minHeight="25em">

        <!-- roma : lat 41.9027835, lon 12.4963655 -->
        <maps:mapView centerX="41.9027835"
                      centerY="12.4963655"
                      zoom="2.6"/>
        </maps:geoMap>

    </initialLayout>

Hello,

Did you try to display the same map with parameters on the normal view?
If it’s working like that, and not while inside the initialLayout, then I remember something about not all containers being able to display the map.
If that’s true, try with this

jmix.ui.default-view-id

Defines a view to be opened after login inside the main view. For example:

jmix.ui.default-view-id = User.list

Kind regards,
Mladen

Hello!

To see the images/tiles of area/world, the GeoMap must contain one raster layer. For instance, it can be OSM tiles: Raster tile providers - OpenStreetMap Wiki or images from Web Map Service or just simple static image.

To see world map from OSM you can try this example (see Layers and Sources :: Jmix Documentation):

<maps:geoMap id="map"
             height="400px"
             width="800px"
             minHeight="25em">
<maps:layers>
    <maps:tile>
        <maps:osmSource/>
    </maps:tile>
</maps:layers>
    <!-- roma : lat 41.9027835, lon 12.4963655 -->
    <maps:mapView centerX="12.4963655"
                  centerY="41.9027835"
                  zoom="2.6"/>
</maps:geoMap>

Also, note that coordinates of Roma should be in different order:

  • X - Longitude
  • Y - Latitude

There is a good explanation of coordinates order in OpenLayers: Why is the order of a coordinate [lon,lat], and not [lat,lon]?

I found solution opening a view I desire triggering before Enter event on MainView

btw, the map should be displayed also if you use my code above.
but when you use the map code in MainView it doesn’t work.
MainView can contain only button or icon … ?

@Route("")
@ViewController(“MainView”)
@ViewDescriptor(“main-view.xml”)
public class MainView extends StandardMainView {
@Override
public void beforeEnter(BeforeEnterEvent event) {
// Set a specific screen as a default page after login in JMIX 2.0

    // Check if the root path is accessed
    if (event.getLocation().getPath().isEmpty()) {
        // Redirect to the Dashboard route when accessing the root path
        event.forwardTo(DashboardView.class);
    }
}

}

InitialLayout is a simple VerticalLayout, so it can contain any component. I tried your code in MainView and the Map is displayed (without layers).

image

What Jmix version do you use? The example above is based on 2.2.3.

My sample project: mainview-map.zip (97.7 KB)