Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lat, Long Bounds of Current View ?

5 REPLIES 5
Reply
Message 1 of 6
Collinda
499 Views, 5 Replies

Lat, Long Bounds of Current View ?

I need to create a custom button labelled 'Download Data'.

When this is clicked it needs to start up a web-page that is fed the bounds of the current view (eg. minimum latitude, maximum latitude, minimum longitude, maximum longitude) in the URL - like so ...

http://...../GeoscienceDataDownLoad.jsp?MAXX=151.0&MAXY=-34.0&MINY=-33.0&MINX=143.0

Can someone give me example code that will get the maximum latitude, etc. for the current view and compose the URL required ?
(or give me some idea what API functions to use?)
5 REPLIES 5
Message 2 of 6
sakkaku
in reply to: Collinda

You can use GetDataExtent() from the MgMap object to get the extents of the data window.

From there the GetLowerLeftCoordinate() will satisfy the min and GetUpperRightCoordinate() will satisfy the maximum.

Then you would need to translate those coordinates into lat/long.

{code}
// Untested code - Have fun

var extent = map.GetDataExtent();

var coordsysfactory = new MgCoordinateSystemFactory();
var coordsys = factory.Create(map.GetMapSRS());

var minbound = coordsys.ConvertToLonLat(extent.GetLowerLeftCoordinate());
var maxbound = coordsys.ConvertToLonLat(extent.GetUpperRightCoordinate());

var querystring = "?MAXX=" maxbound.X + "&MAXY=" + maxbound.Y + "&MINY=" + minbound.Y + "&MINX=" minbound.X;
{code}
Message 3 of 6
Collinda
in reply to: Collinda

Thanks, Sakkaku - looks just what I need.
I'll try it out.
Message 4 of 6
Collinda
in reply to: Collinda

Thanks for the help. I am just having trouble getting started in Mapguide Studio with invoking a script.

The attached image shows the settings for a button that I have created in Mapguide Studio for the 'Toolbar (Main Menu)' and I have chosen to 'Invoke Script'.
The URL of the web layout is -
http://localhost:8008/mapguide2010/fusion/templates/mapguide/slate/index.html?ApplicationDefinition=Library%3a%2f%2fWebMaps%2fDepositsNSW.ApplicationDefinition
The good news is that this works.

The bad news is that if I replace 'alert("hello");' with 'alert(Map.getName());' nothing happens.
I have also tried 'var map = getMap(); alert(map.getName());'
What step am I missing ?
Message 5 of 6
sakkaku
in reply to: Collinda

You will need to use the Web API, not the javascript API to utilize the above sample.
Message 6 of 6
Collinda
in reply to: Collinda

My final solution ...

I am working on a 'Flexible Layout', as recommended by the guide ..

http://images.autodesk.com/adsk/files/mapguide_enterprise_2010_devlopers_guide.pdf

and this seems to be based primarily on 'Fusion', so it seems that I should be using Fusion APIs.

The following is the working javascript code that I ended up with ..

var theMap = Fusion.getMapById("Map");
var theExtent = theMap.getCurrentExtents();
var lbrt = theExtent.toArray();
var bbox = "?MINX=" + lbrt[0] + "&MINY=" + lbrt[1] + "&MAXX=" + lbrt[2] + "&MAXY=" + lbrt[3];
window.open("http://maitdevgi:8081/fmeserver/services/fmedatadownload/GeologicalSurvey/GeoscienceDataDownLoad.fmw" + bbox);

By the way, the guide above has the legacy documentation in chapter 2 and the newer documentation for flexible layouts near the bottom of the document in chapter 9. This confused me. I'd rather have the order reversed.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report