Show Workorder on Google Map

Google Map in Workorder Tracking
Hello;
If you store coordinates in your workorders or location etc. you can show the places on google maps in Maximo. I implemented this on Maximo 6. There are many steps to accomplish this task.. I will tell you about it step by step…
1-You have to get a Google Map api key from this address: http://code.google.com/apis/maps/signup.html .. Write your maximo server address to the textbox and click Generate Key.. Note your key.. We will use it later…
2-Create iframe control: Go to %MAXIMOROOT%\applications\maximo\maximouiweb\webmodule\webclient\controls and create a folder named: iframe. We will send data to google map script from this control. I assume that longitude and latitude are stored in Workorder object as Longitude and Latitude attributes…
Create a jsp file named control.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <%@ include file="../../common/controlheader.jsp" %> <%-- PROPERTY GLOBAL VALUES id true ... height false ### width false ### url false ... --%> <mro:handleevent eventtype="loadinit"> <mro:loadglobalproperties /> <% int height = controlProperties.getInt("height", 100); int width = controlProperties.getInt("width", 100); String url = controlProperties.getString("src"); %> </mro:handleevent> <mro:handleevent eventtype="render"> <% int height = controlProperties.getInt("height", 100); int width = controlProperties.getInt("width", 100); String url = controlProperties.getString("src"); String apptitle = sessionContext.getCurrentApp().getAppTitle(); psdi.util.MXSession mxs=sessionContext.getMXSession(); psdi.mbo.MboSetRemote woSet=mxs.getMboSet("WORKORDER"); woSet.setWhere("WOCLASS in ('WORKORDER', 'ACTIVITY') and istask=0 and boylam is not null and enlem is not null"); System.out.println("WO Count: "+woSet.count()); java.util.ArrayList coordinateList = new java.util.ArrayList(woSet.count()); for(int i=0;i<woSet.count();i++){ java.util.ArrayList coordinate=new java.util.ArrayList(5); psdi.mbo.MboRemote wo=woSet.getMbo(i); coordinate.add(0,wo.getString("WONUM")); coordinate.add(1,wo.getString("DESCRIPTION")); coordinate.add(2,wo.getString("STATUS")); coordinate.add(3,wo.getString("LONGITUDE")); coordinate.add(4,wo.getString("LATITUDE")); coordinateList.add(coordinate); } session.setAttribute("CoordinatesList",coordinateList); %> <iframe src="<%=url%>" height="<%=height%>" width="<%=width%>"> </iframe> </mro:handleevent> <%@ include file="../../common/controlfooter.jsp" %> |
Here we defined iframe control and we added the workorder information to the CoordinatesList variable of session.
Now create another file called allwoongmaps.jsp in the same folder..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title></title> <script src="http://maps.google.com/maps?file=api&v=2&key=<strong>KEY</strong>" type="text/javascript"></script> <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); GEvent.addListener(map, "click", function(overlay, point){ if (point) { map.addOverlay(new GMarker(point)); var msg = "Latitude: "+point.lat()+"<br>"+"Longitude: "+point.lng(); document.getElementById("mypoint").innerHTML = msg; } //close if(point)... }); //close GEvent... var yellowIcon = new GIcon(); yellowIcon.image ="http://esa.ilmari.googlepages.com/markeryellow.png"; yellowIcon.iconSize = new GSize(20, 34); yellowIcon.iconAnchor = new GPoint(9, 34); var turqIcon = new GIcon(); turqIcon.image = "http://www.google.com/uds/samples/places/temp_marker.png"; turqIcon.iconSize = new GSize(20, 34); turqIcon.iconAnchor = new GPoint(9, 34); <% java.util.ArrayList CoordinateList=(java.util.ArrayList) session.getAttribute("CoordinatesList"); for(int i=1;i<CoordinateList.size()+1;i++){ java.util.ArrayList Coordinate=(java.util.ArrayList)CoordinateList.get(i-1); String wonum=(String)Coordinate.get(0); String description=(String)Coordinate.get(1); String status=(String)Coordinate.get(2); String enlem=(String)Coordinate.get(3); String boylam=(String)Coordinate.get(4); double boydouble=Double.parseDouble(boylam); double enlemdouble=Double.parseDouble(enlem); String marker="marker"+i; String point="point"+i; String icon; if(wonum.equalsIgnoreCase("1000")) icon="yellowIcon"; else icon="turqIcon"; if(i==1){ %> map.setUIToDefault(); map.setCenter(new GLatLng(<%=boydouble%>,<%=enlemdouble%>), 5); <%}%> var <%=point%> = new GLatLng(<%=boydouble%>,<%=enlemdouble%>); var <%=marker%>=new GMarker(<%=point%>,{icon:<%=icon%>}); map.addOverlay(<%=marker%>); <% }%> } } </script> </head> <body onload="initialize()" onunload="GUnload()"> <div id="mypoint"></div> <div id="map_canvas" style="width: 470px; height: 200px"></div> </body> </html> |
On line 7 we add our own Google api key that we noted before… and we create our own map from longitude and latitude information on Workorder…
Now open Application Designer and export your application as xml file.Save it and back it up. then add this line to whereever you want.
<iframe src="http://localhost:7001/maximo/webclient/controls/iframe/allwoongmaps.jsp" height="200" width="500" id="genid_headera_4_child_1" />localhost should be your servers ip…;
Save it and import from application designer.. Rebuild and redeploy… You’re going to see map like this…
Tags: google maps, Maximo Connections
April 1st, 2009 at 10:28 am
Hi Burak,
The article looks pretty cool. But what do you mean by:
On line 13 we add our own Google api key that we noted before…
Line 13 describes: (GBrowserIsCompatible()) {
When i implement it, it keeps asking for an object at line 13 in allwoongmaps.jsp.
What do i miss?
Regards,
Frits
April 1st, 2009 at 10:49 am
Hello;
When I google this problem, I got that is a common problem about specific versions of Internet Explorer and google Maps api. You can search google about solutions.. There are different workarounds about it.
Thanks…
April 1st, 2009 at 1:09 pm
ok, thank you.
Regards,
Frits
April 16th, 2009 at 5:20 pm
Hey,
I tried the same in Maximo 7 but it doesn’t works. Can you tell how to achieve the same in Maximo 7 ?
May 1st, 2009 at 4:33 pm
Hello;
Frames are defined in component xml files under properties folder… Try to define them in those 2 xml files..
Have a good day…
May 21st, 2009 at 5:43 pm
Hi
Is it simple to just place another jsp page in a frame in Maximo 7?
I love this google maps idea and I’m experimenting putting a jsp page into an application. I’ve never done anything like this in Maximo and felt that this tutorial would help but haven’t figure it out yet.
Would it be possible to list the steps to simply put a frame into a blank tab in an application?
I’m not sure which bits I do and don’t need from the above tutorial.
Any help is really appreciated.
July 13th, 2009 at 8:44 am
Hi…
Thank you for this tutorial…
How i can catch values about open workorder and send it into iframe?
July 14th, 2009 at 10:37 am
Hello;
You can use these lines in control jsp…
psdi.webclient.system.beans.DataBean db=currentApp.getBeanForApp();
String latitude=db.getString(“LATITUDE”);
String longitude=db.getString(“LONGITUDE”);
Have a good day..
September 30th, 2009 at 1:38 am
Hi,
Thanks for sharing. It’s really helpful for what I am trying to do.
What website address did you use to generate the key? http://IPaddress:Port/maximo, is it correct?
It’s only a localhost IP address that cannot be publicly accessed. Is it ok? Does Google Map API require a pubilc IP address?
October 2nd, 2009 at 7:56 am
Hello;
Google map api requires http://IPaddress:Port/maximo; not the public ip..
Have a good day…
October 27th, 2009 at 5:25 am
Yeah, it works well on my machine.
Just have another question. How can the google map be refreshed when press the next record button on the toolbar? In my case, I put the google map in another tab. I press next record button while the google map tab is open, the map doesn’t show the new one unless I go to ‘Work Order’ tab first.
Any idea? Thank you in advance!!
November 3rd, 2009 at 9:40 am
Hello;
google map is not a maximo page. It is another jsp page. I don’t know a way to refresh the map when the tab changes..
Have a good day…
November 27th, 2009 at 6:45 am
Great idea!
I tried the example but am getting a null pointer exception on the line
java.util.ArrayList CoordinateList=(java.util.ArrayList) session.getAttribute(“CoordinatesList”);
I added some print statements in control.jsp and verified that the array is being populated with work orders. Do you have any idea as to why the call to getAttribute fails. (Maximo 6.2.1 with SQL server and Weblogic)
Do I need to enable session attributes?
I am able to display the map if I comment out all the lines related to the coordinate list and just set the lat/long values to fixed numbers.
Thanks
Tim
<> <[ServletContext(id=514235,name=maximo,context-path=/maximo)] Servlet failed with Exception
java.lang.NullPointerException
at jsp_servlet._webclient._controls._iframe.__allwoongmaps._jspService(__allwoongmaps.java:146)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
December 6th, 2009 at 7:10 pm
Hi,
I am trying to do something similar but I want to open an applet in a dialog box. I created the custom dialog, created the folder for my custom control, created the jsp and made changes to the presentation XML.
I am using the object tag to add the applet code to HTML. The error I am getting is applet parameter CODE missing. The problem is that when maximo is rendering this control, the OBJECT PARAMS are not getting converted to HTML correctly, hence the CODE parameter is not in the HTML and so the error.
Do I have to something differently?
Here is the render part of my JSP.
Java applet that plays a welcoming sound.
Waiting for a reply.
Thank you !!
-Sanjog
December 6th, 2009 at 7:11 pm
Sorry, the
tag didn’t seem to workDecember 21st, 2009 at 2:28 pm
Great article, Burak! Thanks!
Guys, has anyone been able to do this for Maximo 7?
January 18th, 2010 at 8:45 am
Hi there,
Great and interesting article.
I did the following steps that you mentioned. When I tested the of what I have done, I got this error:
The following exception occured in control ‘genid_headera_4_child_1′ (controltype= iframe) for the event ‘render’
java.lang.NullPointerException
I also created the LONGITUDE and LATITUDE fields in WORKORDER table.
Please advise.
Thanks in advance.
February 10th, 2010 at 3:01 pm
Hi,
In your exemple, your call the allwoongmaps.jsp in Maximo XML file (asset.xml). But the control.jsp file, that have the session varaibles. How does allwoongmaps.jsp, get variables in session? Will be mro:handleevent eventtype=”render” call the control.jsp?
I’m using the Maximo 7.
Thanks..
March 11th, 2010 at 5:50 pm
HI ,
I tried ti implement google map using the steps above,
but i am getting following error.
ORA-00904: “ENLEM”: invalid identifier
Please advice
Sachin..!!
March 11th, 2010 at 5:52 pm
To add more to above,
i have added the attribute longitude=75 and latitude=100 for one workorder
March 11th, 2010 at 9:34 pm
Just landed on this place via Google search. I love it. This situation change my perception and I am taking the RSS feeds. Cheers.