Hi,
I am currently leveraging the outsystems maps functionality in my application. From OutSystems maps, I am using the LeafletMap block. In this block I use the "Map_Events\MapEvent" in the placeholder. This event gets triggerend when the end-users zooms in or out. Thus far, this is working perfectly.
My issue: I want to set a marker once the end user has zoomed out to a specific zoom level (let's say zoom5_Continent). However, I am unable to get the currentzoom level of the map. I have tried some JavaScript, however it deemed unsufficient.
Is there anyone that can propose a solution with the current way of working, without having to change to the LeafletMap component?
Kind regards,
Alex
You can try
OutSystems.Maps.MapAPI.MapManager.GetMapById('YOUR_MAP_ID' )._provider.getZoom()
Please share oml file or test link to check the implementation so can suggest you more appropriate solution.
Hey @Alex Ruinen ,
Please check this post; it might help resolve your issue: [OutSystems Maps] Get actual zoom, center values.
Hey @Mihai Melencu,
Thank you for the quick reply! This is a post I haven't found before.
I tried implementing first: "$parameters.CurrentZoom = MapAPI.MapManager.GetMapById($parameters.MapWidgetId)._provider.zoom ". This resulting in:
"An error was raised by the application: Cannot assign a JavaScript undefined with value undefined to an output parameter of type Text Check the JavaScript node 'JavaScript1' of the action 'OnZoomChange'."
Together with a not further to mention program, I came to the code:"var zoom = MapAPI.MapManager.GetMapById($parameters.MapWidgetId)._provider.zoom;
// Controleer of zoom een geldige waarde heeft
if (zoom !== undefined && zoom !== null) {
$parameters.CurrentZoom = zoom.toString(); //
} else {
$parameters.CurrentZoom = "Empty"; //
}"This resulting in an output "Empty".
Any tips on how to proceed?
Hi, do you have an OML that you can share with that error?
Thank you @Mihai Melencu and @Navneet Garg for the quick respones and pointing me in the right direction. Your solution works, Naveet.
Thank you both!
Glad to know that solution work for you. always happy to help.
The action of the Map_Events\MapEvent widget is incredibly powerful—it provides you with the JavaScript object of the Map that triggered the event. This means you can easily access the details of the specific map, making your development implementation easier!
When you pass an object into a JavaScript node, you can interact with that object directly. This approach simplifies the process by eliminating DOM traversal to access the object and ensures you interact with the map object that triggered the event.
For more OutSystems context, see https://outsystemsui.outsystems.com/OutSystemsMapsSample/Map section `Events > MapEvent`.
For additional insight into the available Google Maps methods, see https://developers.google.com/maps/documentation/javascript/reference/map#Map
Here is an example of the implementation in ODC.