Re: [mapguide-users] Fusion and Digitizing
I figured this out - there is a ClearDigitization function within the MapGuideViewerApi.js which works a treat :) - Software-Matters -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Fusion-and-Digitizing-tp4183831p5077688.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
Re: [mapguide-users] Fusion and Digitizing
Hi Rodolfo, Hope you can help... I have created a page (using MG 2.5 on Windows and IE10) that uses your code to digitize a polygon which works great but I am still getting an issue with the polygon getting left behind and I can't seem to get the clear function to work. Below is what I'm calling from a button in my taskpane and I've got a link to the mapguideAPI.js file which contains your code. input type=button onClick=clearPol(); value=clear When I click the button nothing happens - can you help? - Software-Matters -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Fusion-and-Digitizing-tp4183831p5077113.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
Re: [mapguide-users] Fusion and Digitizing
In Fusion 2.0, we can certainly clear the digitized features by calling the Vector layer destroyFeatures() method. I'm not familiar with the behaviour of the old viewers that MapGuideViewerAPI is trying to mimic so I would need to know when the features should be cleared: when you start drawing another feature? always after the handler is called? Mike Paul Spencer wrote: Thanks guys ... the digitizing code has changed in the upcoming 2.0 release to use the OpenLayers vector library rather than our home-grown canvas implementation so we'll make sure there is a way to clean up after digitizing ... Mike, can you take a skim through this thread and make sure the new Vector implementation has a method for cleaning up, or implicitly cleans up if possible. Cheers Paul On 29-Jan-09, at 6:14 PM, Mark Pendergraft wrote: thanks! I'll take a look at it later tonight. -Mark -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Rodolfo Moreno Sent: Thursday, January 29, 2009 3:02 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing Hi Mark, I have gotten to clear the digitized polygons in FUSION viewer by modifying the MapGuideViewerapi.js var polDigitizer; function DigitizePolygon(handler) { if (handler) { var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); var digitizer = new Fusion.Tool.Canvas.Polygon(mapWidget); digitizer.mouseDown = MultiPointHandlers.prototype.mouseDown; digitizer.mouseMove = MultiPointHandlers.prototype.mouseMove; digitizer.dblClick = MultiPointHandlers.prototype.dblClick; Object.inheritFrom(digitizer, Fusion.Tool.Canvas.prototype, []); digitizer.handler = handler; digitizer.activateCanvas(); polDigitizer = digitizer; //add a listener to update the position of the features var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse ); } } function extendEvtResponse(){ var digitizer = polDigitizer; digitizer.updatePx(); digitizer.clearContext(); digitizer.draw(digitizer.context); } function clearPol(){ polDigitizer.clearContext(); var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.deregisterForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse); polDigitizer.deactivateCanvas(); } In your main page you must call to clearPol() function in order to clear the digitized polygon. For the other shapes I guess that the logic is the same. The above code only clears the last polygon digitized. It's necessary to manage an array of digitizers for controlling all digitized polygons. I haven't had time for trying it. I have tested with mapguide 2.0.1 with FUSION 1.0.6 in IE7 and FF2 maybe you can improve it. Regards, GordonL wrote: Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map
Re: [mapguide-users] Fusion and Digitizing
Yes, that's correct, it should work with 2.0 but not with the templates. The new templates are in mapguide svn and should work with a 2.0 installation too. Mike plowed through a bunch of tickets last week but there are still a couple of key issues to address so the 2.0 beta will be delayed a few days. I was going to blame Jason ;) but instead lets say we are synchronizing our watches ... Cheers Paul On 30-Jan-09, at 1:33 PM, Jason Birch wrote: An alpha of MGOS 2.1 (including Fusion 2.0 beta) is supposed to be ready by end of month, but I'm going to have a couple really late nights if I'm going to make that :) Paul, correct me if I'm wrong, but I think that Fusion 2.0 will run against MGOS 2.0, though some of the performance enhancements may be 2.1-specific with 2.0 fallbacks. All templates will need to be rewritten though because of considerable changes to the Jx library and the Fusion underpinnings. Jason -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Mark Pendergraft Sent: January-30-09 8:28 AM To: MapGuide Users Mail List Subject: RE: [mapguide-users] Fusion and Digitizing Even better news! Any word on when the 2.0 beta will be available? -Mark ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
Re: [mapguide-users] Fusion and Digitizing
Thanks guys ... the digitizing code has changed in the upcoming 2.0 release to use the OpenLayers vector library rather than our home- grown canvas implementation so we'll make sure there is a way to clean up after digitizing ... Mike, can you take a skim through this thread and make sure the new Vector implementation has a method for cleaning up, or implicitly cleans up if possible. Cheers Paul On 29-Jan-09, at 6:14 PM, Mark Pendergraft wrote: thanks! I'll take a look at it later tonight. -Mark -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Rodolfo Moreno Sent: Thursday, January 29, 2009 3:02 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing Hi Mark, I have gotten to clear the digitized polygons in FUSION viewer by modifying the MapGuideViewerapi.js var polDigitizer; function DigitizePolygon(handler) { if (handler) { var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); var digitizer = new Fusion.Tool.Canvas.Polygon(mapWidget); digitizer.mouseDown = MultiPointHandlers.prototype.mouseDown; digitizer.mouseMove = MultiPointHandlers.prototype.mouseMove; digitizer.dblClick = MultiPointHandlers.prototype.dblClick; Object.inheritFrom(digitizer, Fusion.Tool.Canvas.prototype, []); digitizer.handler = handler; digitizer.activateCanvas(); polDigitizer = digitizer; //add a listener to update the position of the features var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse ); } } function extendEvtResponse(){ var digitizer = polDigitizer; digitizer.updatePx(); digitizer.clearContext(); digitizer.draw(digitizer.context); } function clearPol(){ polDigitizer.clearContext(); var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.deregisterForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse); polDigitizer.deactivateCanvas(); } In your main page you must call to clearPol() function in order to clear the digitized polygon. For the other shapes I guess that the logic is the same. The above code only clears the last polygon digitized. It's necessary to manage an array of digitizers for controlling all digitized polygons. I haven't had time for trying it. I have tested with mapguide 2.0.1 with FUSION 1.0.6 in IE7 and FF2 maybe you can improve it. Regards, GordonL wrote: Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon
RE: [mapguide-users] Fusion and Digitizing
Even better news! Any word on when the 2.0 beta will be available? -Mark -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Paul Spencer Sent: Friday, January 30, 2009 4:16 AM To: MapGuide Users Mail List Cc: Mike Adair Subject: Re: [mapguide-users] Fusion and Digitizing Thanks guys ... the digitizing code has changed in the upcoming 2.0 release to use the OpenLayers vector library rather than our home- grown canvas implementation so we'll make sure there is a way to clean up after digitizing ... Mike, can you take a skim through this thread and make sure the new Vector implementation has a method for cleaning up, or implicitly cleans up if possible. Cheers Paul On 29-Jan-09, at 6:14 PM, Mark Pendergraft wrote: thanks! I'll take a look at it later tonight. -Mark -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Rodolfo Moreno Sent: Thursday, January 29, 2009 3:02 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing Hi Mark, I have gotten to clear the digitized polygons in FUSION viewer by modifying the MapGuideViewerapi.js var polDigitizer; function DigitizePolygon(handler) { if (handler) { var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); var digitizer = new Fusion.Tool.Canvas.Polygon(mapWidget); digitizer.mouseDown = MultiPointHandlers.prototype.mouseDown; digitizer.mouseMove = MultiPointHandlers.prototype.mouseMove; digitizer.dblClick = MultiPointHandlers.prototype.dblClick; Object.inheritFrom(digitizer, Fusion.Tool.Canvas.prototype, []); digitizer.handler = handler; digitizer.activateCanvas(); polDigitizer = digitizer; //add a listener to update the position of the features var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse ); } } function extendEvtResponse(){ var digitizer = polDigitizer; digitizer.updatePx(); digitizer.clearContext(); digitizer.draw(digitizer.context); } function clearPol(){ polDigitizer.clearContext(); var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.deregisterForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse); polDigitizer.deactivateCanvas(); } In your main page you must call to clearPol() function in order to clear the digitized polygon. For the other shapes I guess that the logic is the same. The above code only clears the last polygon digitized. It's necessary to manage an array of digitizers for controlling all digitized polygons. I haven't had time for trying it. I have tested with mapguide 2.0.1 with FUSION 1.0.6 in IE7 and FF2 maybe you can improve it. Regards, GordonL wrote: Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing
RE: [mapguide-users] Fusion and Digitizing
An alpha of MGOS 2.1 (including Fusion 2.0 beta) is supposed to be ready by end of month, but I'm going to have a couple really late nights if I'm going to make that :) Paul, correct me if I'm wrong, but I think that Fusion 2.0 will run against MGOS 2.0, though some of the performance enhancements may be 2.1-specific with 2.0 fallbacks. All templates will need to be rewritten though because of considerable changes to the Jx library and the Fusion underpinnings. Jason -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Mark Pendergraft Sent: January-30-09 8:28 AM To: MapGuide Users Mail List Subject: RE: [mapguide-users] Fusion and Digitizing Even better news! Any word on when the 2.0 beta will be available? -Mark ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
RE: [mapguide-users] Fusion and Digitizing
You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); //here you would send your geomText to a web service, or aspx page that would turn the coordinates into a linear ring //and then a polygon from there. The geomText variable (in this particular situation) evaluates to something similar to //3,5000.00,5000.00,5050.00,5050.00,5100.00,5100.00 } Of course you can format the way the coordinates are sent to your application any way you want. I would also recommend calling the DigitizePolygon() function from an InvokeScript() widget, as I had some problems when I tried to actually create a widget and call it from there. Also, I prefer to change my cursor when the widget is activated, you can see I put it back to 'auto' in the CreateJobByPolygon() function, but I like to set it to 'crosshair' before the DigitizePolygon function is called. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Stefan Dalakov Sent: Friday, January 23, 2009 12:35 PM To: MapGuide Users Mail List Subject: [mapguide-users] Fusion and Digitizing Hi all, From what I read here, should I conclude that digitizing functions in Fusion are not yet fully supported ? I need to digitize a polygon on the map and save it permanently. I have this working with AJAX viewer, but would like to port it to Fusion Has anyone succeeded to do this ? Stefan Dalakov ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users -- View this message in context: http://n2.nabble.com/Fusion-and-Digitizing-tp2205560p2241352.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
RE: [mapguide-users] Fusion and Digitizing
I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); //here you would send your geomText to a web service, or aspx page that would turn the coordinates into a linear ring //and then a polygon from there. The geomText variable (in this particular situation) evaluates to something similar to //3,5000.00,5000.00,5050.00,5050.00,5100.00,5100.00 } Of course you can format the way the coordinates are sent to your application any way you want. I would also recommend calling the DigitizePolygon() function from an InvokeScript() widget, as I had some problems when I tried to actually create a widget and call it from there. Also, I prefer to change my cursor when the widget is activated, you can see I put it back to 'auto' in the CreateJobByPolygon() function, but I like to set it to 'crosshair' before the DigitizePolygon function is called. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Stefan Dalakov Sent: Friday, January 23, 2009 12:35 PM To: MapGuide Users Mail List Subject: [mapguide-users] Fusion and Digitizing Hi all, From what I read here, should I conclude that digitizing functions in Fusion are not yet fully supported ? I need to digitize a polygon on the map and save it permanently. I have this working with AJAX viewer, but would like to port it to Fusion Has anyone succeeded to do this ? Stefan Dalakov ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users -- View this message in context: http://n2.nabble.com/Fusion-and-Digitizing-tp2205560p2241352.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
RE: [mapguide-users] Fusion and Digitizing
Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); // here you would send your geomText to a web service, or aspx page that would turn the coordinates into a linear ring //and then a polygon from there. The geomText variable (in this particular situation) evaluates to something similar to //3,5000.00,5000.00,5050.00,5050.00,5100.00,5100.00 } Of course you can format the way the coordinates are sent to your application any way you want. I would also recommend calling the DigitizePolygon() function from an InvokeScript() widget, as I had some problems when I tried to actually create a widget and call it from there. Also, I prefer to change my cursor when the widget is activated, you can see I put it back to 'auto' in the CreateJobByPolygon() function, but I like to set it to 'crosshair' before the DigitizePolygon function is called. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Stefan Dalakov Sent: Friday, January 23, 2009 12:35 PM To: MapGuide Users Mail List Subject: [mapguide-users] Fusion and Digitizing Hi all, From what I read here, should I conclude that digitizing functions in Fusion are not yet fully supported ? I need to digitize a polygon on the map and save it permanently. I have this working with AJAX viewer, but would like to port it to Fusion Has anyone succeeded to do this ? Stefan Dalakov ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users -- View this message in context: http://n2.nabble.com/Fusion-and-Digitizing-tp2205560p2241352.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide
RE: [mapguide-users] Fusion and Digitizing
Hi Mark, I have gotten to clear the digitized polygons in FUSION viewer by modifying the MapGuideViewerapi.js var polDigitizer; function DigitizePolygon(handler) { if (handler) { var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); var digitizer = new Fusion.Tool.Canvas.Polygon(mapWidget); digitizer.mouseDown = MultiPointHandlers.prototype.mouseDown; digitizer.mouseMove = MultiPointHandlers.prototype.mouseMove; digitizer.dblClick = MultiPointHandlers.prototype.dblClick; Object.inheritFrom(digitizer, Fusion.Tool.Canvas.prototype, []); digitizer.handler = handler; digitizer.activateCanvas(); polDigitizer = digitizer; //add a listener to update the position of the features var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse ); } } function extendEvtResponse(){ var digitizer = polDigitizer; digitizer.updatePx(); digitizer.clearContext(); digitizer.draw(digitizer.context); } function clearPol(){ polDigitizer.clearContext(); var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.deregisterForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse); polDigitizer.deactivateCanvas(); } In your main page you must call to clearPol() function in order to clear the digitized polygon. For the other shapes I guess that the logic is the same. The above code only clears the last polygon digitized. It's necessary to manage an array of digitizers for controlling all digitized polygons. I haven't had time for trying it. I have tested with mapguide 2.0.1 with FUSION 1.0.6 in IE7 and FF2 maybe you can improve it. Regards, GordonL wrote: Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); // here you would send your geomText to a web service, or aspx page that would turn the coordinates into a linear ring //and then a polygon from there. The geomText variable (in this particular situation) evaluates to something similar to //3,5000.00,5000.00,5050.00,5050.00,5100.00,5100.00 } Of course you can format the way the coordinates are sent to your application any way you want. I would
RE: [mapguide-users] Fusion and Digitizing
thanks! I'll take a look at it later tonight. -Mark -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Rodolfo Moreno Sent: Thursday, January 29, 2009 3:02 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing Hi Mark, I have gotten to clear the digitized polygons in FUSION viewer by modifying the MapGuideViewerapi.js var polDigitizer; function DigitizePolygon(handler) { if (handler) { var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); var digitizer = new Fusion.Tool.Canvas.Polygon(mapWidget); digitizer.mouseDown = MultiPointHandlers.prototype.mouseDown; digitizer.mouseMove = MultiPointHandlers.prototype.mouseMove; digitizer.dblClick = MultiPointHandlers.prototype.dblClick; Object.inheritFrom(digitizer, Fusion.Tool.Canvas.prototype, []); digitizer.handler = handler; digitizer.activateCanvas(); polDigitizer = digitizer; //add a listener to update the position of the features var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse ); } } function extendEvtResponse(){ var digitizer = polDigitizer; digitizer.updatePx(); digitizer.clearContext(); digitizer.draw(digitizer.context); } function clearPol(){ polDigitizer.clearContext(); var Fusion = window.top.Fusion; var mapWidget = Fusion.getWidgetById(mapWidgetId); mapWidget.deregisterForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, extendEvtResponse); polDigitizer.deactivateCanvas(); } In your main page you must call to clearPol() function in order to clear the digitized polygon. For the other shapes I guess that the logic is the same. The above code only clears the last polygon digitized. It's necessary to manage an array of digitizers for controlling all digitized polygons. I haven't had time for trying it. I have tested with mapguide 2.0.1 with FUSION 1.0.6 in IE7 and FF2 maybe you can improve it. Regards, GordonL wrote: Hi Mark, I know what you mean about the sticky digitizing... I was told to look at the resetCanvas function in the Measure.js file to get rid of that leftover digitize graphics...but I haven't tried it yet... gordon Mark Pendergraft wrote: I was in no way implying the wheel should be reinvented, in fact the code I posted was an example of how to use the MapGuideViewerAPI.js supplied DigitizePolygon(handler) function that you referred to. I did say that I would like to see some method to clear the digitized shapes after the function's handler has been called. In MGOS 1.2 after a polygon was digitized, it was destroyed. In MGOS 2 with Fusion 1.1, the polygon stays on the map until the user closes their browser. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of GordonL Sent: Thursday, January 29, 2009 1:20 PM To: mapguide-users@lists.osgeo.org Subject: RE: [mapguide-users] Fusion and Digitizing You know, you really do not need to reinvent the wheel, if you have already built a lot of code with the Basic Web Layouts. Did you know that Fusion supports some retro digitizing methods? For example, I put the following in an INVOKESCRIPT in the Flexible Web Layout: top.parent.DigitizePoint(top.OnPointDigitized); I also have the OnPointDigitized in a JS file attached to the main frame/window. So I reuse my code for both FUSION and Basic Web Layouts... Just check out the functions in the MapGuideViewerApi.js in the /www/fusion/MapGuide/ folder... They include: Refresh() SetSelectionXML(selectionXml) ZoomToView(x, y, scale, refresh) DigitizePoint(handler) DigitizeLine(handler) DigitizeLineString(handler) DigitizeRectangle(handler) DigitizePolygon(handler) They work just like the classic MapGuide Viewer API...pretty sweet. gordon Mark Pendergraft wrote: Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); // here you would send your geomText to a web service, or aspx page that would turn
RE: [mapguide-users] Fusion and Digitizing
Absolutely. My biggest beef with digitizing in Fusion is that when you digitize an object (point/polygon/etc.) it stays on the map. The existing functions don't have a clear method to remove the digitized object, and my programming skills aren't good enough that I want to mess with it. It's very simple, Add a reference to MapGuideViewerApi.js and call DigitizePolygon() The DigitizePolygon function requires that you pass it a handler Something similar to the following: DigitizePolygon(CreateJobByPolygon); function CreateJobByPolygon(polygon) { var geomText = polygon.Count; for (var i = 0; i polygon.Count; i++){ geomText += , + polygon.Point(i).X + , + polygon.Point(i).Y; } Fusion.getWidgetById('Map').setCursor('auto'); // here you would send your geomText to a web service, or aspx page that would turn the coordinates into a linear ring //and then a polygon from there. The geomText variable (in this particular situation) evaluates to something similar to //3,5000.00,5000.00,5050.00,5050.00,5100.00,5100.00 } Of course you can format the way the coordinates are sent to your application any way you want. I would also recommend calling the DigitizePolygon() function from an InvokeScript() widget, as I had some problems when I tried to actually create a widget and call it from there. Also, I prefer to change my cursor when the widget is activated, you can see I put it back to 'auto' in the CreateJobByPolygon() function, but I like to set it to 'crosshair' before the DigitizePolygon function is called. -Mark P. -Original Message- From: mapguide-users-boun...@lists.osgeo.org [mailto:mapguide-users-boun...@lists.osgeo.org] On Behalf Of Stefan Dalakov Sent: Friday, January 23, 2009 12:35 PM To: MapGuide Users Mail List Subject: [mapguide-users] Fusion and Digitizing Hi all, From what I read here, should I conclude that digitizing functions in Fusion are not yet fully supported ? I need to digitize a polygon on the map and save it permanently. I have this working with AJAX viewer, but would like to port it to Fusion Has anyone succeeded to do this ? Stefan Dalakov ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users