Select to view content in your preferred language

Enhanced Bookmark - Save Bookmarks

5226
11
Jump to solution
12-06-2012 03:38 AM
JeffersonFerreira_Ferreira
Deactivated User
Dear Colleagues;

I'm using the Enhanced Bookmark Widget (http://www.arcgis.com/home/item.html?id=ed4d8dbef33d400499d2cc6475f24a4e) and it's great. But i'm trying to make a little adaptation with no success. Instead save only the user-defined bookmarks I want to save all bookmarks - including the bookmarks defined in xml by the developer. By default it's not possible (only user defined), but it's quite simple, I guess. If someone can give me a hand I will be greatful. Below part of the mxml the execute the save function.


// mjk - Enhanced Bookmark    /**     * Parses bookmarks from the default widget config file or      * a file loaded by the user. In the case of a user created      * config file set isUserCreated to true so that they behave the      * same as bookmarks added at run time.      **/    private function parseBookmarkConfig(config:XML, isUserCreated:Boolean):void    {     if(config)     {      var bookmarkList:XMLList = config..bookmark;      var length:int = bookmarkList.length();            if(length < 1)      {       Alert.show("Nenhuma marcação válida encontrada!", wTemplate.widgetTitle);       return;      }            for (var i:int = 0; i < length; i++)      {       // mjk- Enhanced Bookmark       var comment:String = bookmarkList.@comment;             var name:String = bookmarkList.@name;       var extent:String = bookmarkList;       var extArray:Array = extent.split(" ");       var bookmark:Bookmark = new Bookmark();             //mjk - Enhanced Bookmark       bookmark.comment = comment;       bookmark.userCreated = isUserCreated;              bookmark.name = name;       bookmark.xmin = Number(extArray[0]);       bookmark.ymin = Number(extArray[1]);       bookmark.xmax = Number(extArray[2]);       bookmark.ymax = Number(extArray[3]);       bookmarkAL.addItem(bookmark);              // mjk - Enhanced Bookmark        // Add user created bookmarks to bookmarkSOAL       if(isUserCreated)       {        bookmarkSOAL.addItem(bookmark);       }      }     }    }                 private function addBookmark():void             {                 var name:String = txtName.text;                 if (name)                 {                     var ext:Extent = map.extent;                     var bookmark:Bookmark = new Bookmark();                     bookmark.name = name;            // mjk - Enhanced Bookmark      bookmark.comment = txtAreaComment.text;                           bookmark.userCreated = true;                     bookmark.xmin = Number(ext.xmin.toFixed(4));                     bookmark.ymin = Number(ext.ymin.toFixed(4));                     bookmark.xmax = Number(ext.xmax.toFixed(4));                     bookmark.ymax = Number(ext.ymax.toFixed(4));                     bookmarkAL.addItem(bookmark);                     bookmarkSOAL.addItem(bookmark);                     saveBookmarks();                     txtName.text = "";            // mjk - Enhanced Bookmark      txtAreaComment.text = "";                           bkmList.addEventListener(EffectEvent.EFFECT_END, bkmList_effectEndHandler);                     showBookmarksList();                 }                 else                 {                     Alert.show(errorLabel, wTemplate.widgetTitle);                 }             }              private function bkmList_effectEndHandler(event:EffectEvent):void             {                 bkmList.removeEventListener(EffectEvent.EFFECT_END, bkmList_effectEndHandler);                 // scroll to the bottom                 bookmarkDG.verticalScrollPosition += bookmarkDG.layout.getVerticalScrollPositionDelta(NavigationUnit.END);             }              private function removeBookmark(event:Event):void             {                 var bookmark:Bookmark = ItemRenderer(event.target).data as Bookmark;                 bookmarkAL.removeItem(bookmark);                 bookmarkSOAL.removeItem(bookmark);                 saveBookmarks();             }              private function saveBookmarks():void             {                 if (bookmarkSO)                 {                     try                     {                         bookmarkSO.flush();                     }                     catch (err:Error)                     {                         trace(err);                     }                 }             }              private function showBookmark(event:Event):void             {                 var bookmark:Bookmark = ItemRenderer(event.target).data as Bookmark;                 var ext:Extent = new Extent(bookmark.xmin, bookmark.ymin, bookmark.xmax, bookmark.ymax);                 map.extent = ext;             }        // mjk - Enhanced Bookmark    /**     * Saves user created bookmarks to a file.     * The xml schema is the same as the widgets.     **/    private function saveBooksMarksToFile():void    {     if(bookmarkSOAL)     {      var xml:XML = createBookmarksXML();            if(!xml) return;            fileReference = new FileReference();      fileReference.save(xml, "LocaisWebSIG.txt");     }    }    
Tags (2)
0 Kudos
11 Replies
MarcinDruzgala
Frequent Contributor
I'm glad I could help:)

Just to relate to your last question I was compiling and running this widget with flex 4.6 SDK - so that is still a mystery why you had a problem...but it's working now:)

Good luck with your app!

Regards,
MDruzgala
0 Kudos
ScottMcGee
Regular Contributor
As far as I know, this widget (Enhanced Bookmark) has not been upgraded to Flex 3.1. The last activity on this forum about the widget was last December. Does anyone know if the solution offered in message #6 above will work with 3.1?

I downloaded version 2.2 of the widget from http://www.arcgis.com/home/item.html?id=ed4d8dbef33d400499d2cc6475f24a4e and installed it, but it doesn't work. When I click the widget's icon on the Header Controller, the icon just bounces up and down, but the interface for it doesn't open.

Is anyone using the Enhanced Bookmark widget with Flex 3.1?
0 Kudos