Skip to main content

Hi,
I basically need the corner coordinates of the visible map in the Map Widget. Please see the red dots below:
 

 These coordinates will be needed when an action is triggered (e.g., a button is pressed), so they don’t need to be tracked continuously.

Thanks.

Hello @gorkem, unfortunatelly this is not supported on our Map Widget. 


Indeed, that is unfortunately the correct answer.

The Map widget gives you (read/write) access to the latitude and longitude of the center of the map,  and the zoom setting, but other map details are not accessible.

The corner coordinates of the displayed area of course depend on the zoom setting but also the size of the user’s screen and resulting widget size. Details that are also not shared back to the AIMMS model.

If all of your users would be using very similar screen settings, then I guess you could roughly estimate the area with a hand-made look-up table for the map scale at each zoom setting, and calculate it. But it would not be very reliable, given the liberty users have to resize their window in all kinds of ways.

Accessing the internals of the Map library we use for the actual display of the map (Leaflet), which knows very well what the exact coordinates are, is not something we cater for right now. It would not be impossible, but requires us to add the feature to the Widget and it would be different in the sense that it needs to be read-only and updated real-time from changes in the browser environment; I don’t think we have anything in that category yet.

You could suggest it as a feature request here on the community and maybe find other developers who’d appreciate it. Maybe there are other ‘environment characteristics’ worth sharing back to AIMMS too.


Hi @Edo Nijmeijer ,

Before asking the question I actually did some research on the Map Widget knowing that it is a Leaflet object and found this stackoverflow answer:


https://stackoverflow.com/questions/22948096/get-the-bounding-box-of-the-visible-leaflet-map

Turns out that .getBounds() is supposed to do that, but it’s not accessible in AIMMS. The Map Widget is the most important one for showing off  the results and getting the attention of the users. It would be great to be able to access all the available functions in Leaflet. Our users spend their time mostly using the Map Widget and they also want flexibility like selecting multiple nodes by drawing shapes on the map (and then tying an action to the selected nodes) as well. 

Thanks for the answer. I will definitely make those requests and see the reaction of the community.

Best
Gorkem

 

  


Thanks, Gorkem, for considering to create a feature request for your needs.

I recognize the important role the map widget can play in an application. Which makes it all the more important to keep it stable and as performant as possible.

Adding access to map properties like the current corner coordinates, through AIMMS, fits in there perfectly, in my opinion.

Being able to make selections on the map, “freehand” or even just square, seems like a challenge to get right without disturbing other basic interactions with the map layers (dragging, selecting)
Using the corner coordinates of the viewport (once you’d have those) seems safer. A bit like Google Maps’ ‘search this area’. But I guess it depends on what you need from the map and the accuracy of the selection.

Giving (full) access to the Leaflet library also jeopardizes the way in which we can expect the map to represent the model data, being in sync in two directions. Which again is something which might be acceptable for specific applications, but maybe not for ‘everyone’.

Having said that, WebUI does allow for Custom Widgets to be added, but building a map-like widget from the ground up is probably not a fun exercise either. I can imagine.

So when you put in those feature request(s), make sure that our Product Owner @Madhu Krishnappa can understand the purpose and value of the feature, so we might be able to break it down into separate parts or match it with requests that he already knows might exist.

Thanks for sharing!

 


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator