I am wanting to change properties on a polyline once it is on the map, I can call methods such as setWeight to change the line thickness, but this simply changes the property on the mxn.polyline object. How is it intended to push these changes through to the displayed underlying object? I see 2 potential options, 1) create an update method to apply all the properties if the line exists. 2) change the polyline methods (ie setWeight) to be required on the underlying provider objects and not exist in the mxn.core. Official advice please? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100222/7c890a15/attachment.htm>
Hi Sam, I think the standard way in Mapstraction is to remove the object from the map, change it and then re-add it. There is already an update method for polylines however this if for doing the opposite - updating the Mapstraction object with any changes that have been made to the proprietary one. Maybe there is scope for doing property amends however I''m not sure how well that is supported across the various providers, would need some investigation. Thanks, Derek On 22 February 2010 14:49, <nojunksam at email2me.net> wrote:> > I am wanting to change properties on a polyline once it is on the map, I > can call methods such as setWeight to change the line thickness, but this > simply changes the property on the mxn.polyline object. How is it intended > to push these changes through to the displayed underlying object? I see 2 > potential options, > > 1) create an update method to apply all the properties if the line exists. > 2) change the polyline methods (ie setWeight) to be required on the > underlying provider objects and not exist in the mxn.core. > > Official advice please? > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com > >-- Derek Fowler m. +44 (0) 7966 512 369 e. dezfowler at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100222/7c5dc696/attachment.htm>
This might be ok for updating one or 2 items at a time although I want to change properties in the mouseover which needs to be responsive. Also later I will be upating multiple items to reflect real time information so removing each item may cause nasty flickering. Maybe option 2 would help here. -----Original Message----- From: Derek Fowler <dezfowler at gmail.com> To: nojunksam at email2me.net Cc: mapstraction at lists.mapstraction.com Sent: Mon, Feb 22, 2010 4:23 pm Subject: Re: [Mapstraction] v2 polyline properties Hi Sam, I think the standard way in Mapstraction is to remove the object from the map, change it and then re-add it. There is already an update method for polylines however this if for doing the opposite - updating the Mapstraction object with any changes that have been made to the proprietary one. Maybe there is scope for doing property amends however I''m not sure how well that is supported across the various providers, would need some investigation. Thanks, Derek On 22 February 2010 14:49, <nojunksam at email2me.net> wrote: I am wanting to change properties on a polyline once it is on the map, I can call methods such as setWeight to change the line thickness, but this simply changes the property on the mxn.polyline object. How is it intended to push these changes through to the displayed underlying object? I see 2 potential options, 1) create an update method to apply all the properties if the line exists. 2) change the polyline methods (ie setWeight) to be required on the underlying provider objects and not exist in the mxn.core. Official advice please? _______________________________________________ Mapstraction mailing list Mapstraction at lists.mapstraction.com http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com -- Derek Fowler m. +44 (0) 7966 512 369 e. dezfowler at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100223/4bf35d04/attachment.htm>
I see, interesting, would be good to get some input from the list to see if anyone has done something similar and how the accomplished it. Sounds like you may need to place some custom html on the map and ensure it stays in position as the map is panned and zoomed which the library may be able to support. Derek On Feb 23, 2010 8:39 AM, <nojunksam at email2me.net> wrote: This might be ok for updating one or 2 items at a time although I want to change properties in the mouseover which needs to be responsive. Also later I will be upating multiple items to reflect real time information so removing each item may cause nasty flickering. Maybe option 2 would help here. -----Original Message----- From: Derek Fowler <dezfowler at gmail.com> To: nojunksam at email2me.net Cc... _______________________________________________ Mapstraction mailing list Mapstraction at lists.mapstraction.com http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100223/5fe0d960/attachment.htm>
Just to recap, I want to be able to alter properties of polylines and markers that are on the map to reflect changing data without having to remove and readd the items to the map as this will be slow and also visually bad for the user. For example if the user moves the mouse over a line I want to make it thicker so they can check which line they are pointing at. I''ve tried out something to see if it works, and I''d like some feedback on whether there is a better way to achieve this with mapstraction. By the way I have added extra events to the polyline object to do this as mouseover/out are not currently supported to allow the control over this to be at the application level. I have added a new method called setProprietaryWidth to the proxy methods for the polyline. mxn.addProxyMethods(Polyline, [ ''setProprietaryWidth'' ''setProprietaryWidth'' ]); in the google provider code I have implemented the setProprietaryWidth method setProprietaryWidth: function() { if(this.proprietary_polyline) { this.proprietary_polyline.setStrokeStyle({weight : this.width}); } } And changed the setWidth in mxn.core to /** * Stroke width of the polyline * @param {Integer} width */ Polyline.prototype.setWidth = function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method this.width = width; // the polyline has been linked to an api so call the proprietary method // the polyline has been linked to an api so call the proprietary method if(this.api) { this.setProprietaryWidth(); } }; if(this.api) { this.setProprietaryWidth(); } }; this.setProprietaryWidth(); } }; function() { if(this.proprietary_polyline) { this.proprietary_polyline.setStrokeStyle({weight : this.width}); } } And changed the setWidth in mxn.core to /** * Stroke width of the polyline * @param {Integer} width */ Polyline.prototype.setWidth = function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method this.width = width; // the polyline has been linked to an api so call the proprietary method // the polyline has been linked to an api so call the proprietary method if(this.api) { this.setProprietaryWidth(); } }; if(this.api) { this.setProprietaryWidth(); } }; this.setProprietaryWidth(); } }; if(this.proprietary_polyline) { this.proprietary_polyline.setStrokeStyle({weight : this.width}); } } And changed the setWidth in mxn.core to /** * Stroke width of the polyline * @param {Integer} width */ Polyline.prototype.setWidth = function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method this.width = width; // the polyline has been linked to an api so call the proprietary method // the polyline has been linked to an api so call the proprietary method if(this.api) { this.setProprietaryWidth(); } }; if(this.api) { this.setProprietaryWidth(); } }; this.setProprietaryWidth(); } }; this.proprietary_polyline.setStrokeStyle({weight : this.width}); } } And changed the setWidth in mxn.core to /** * Stroke width of the polyline * @param {Integer} width */ Polyline.prototype.setWidth = function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method function(width){ this.width = width; // the polyline has been linked to an api so call the proprietary method this.width = width; // the polyline has been linked to an api so call the proprietary method // the polyline has been linked to an api so call the proprietary method if(this.api) { this.setProprietaryWidth(); } }; if(this.api) { this.setProprietaryWidth(); } }; this.setProprietaryWidth(); } }; This works by updating the width property of the polyline object as before, but if the api property of the line has been set then the line has been added to the map, so in this case the setProprietaryWidth is called which updates the google polyline with the property of the width. I just call setWidth from a handler on the mouse events. It works well but, to extend means changing all other methods to the similar pattern. My concern with this approach is that the setProprietyWidth is a pubic method, whereas Ideally it should only be able to be called from within the mapstraction polyline objects methods. So my question is, is there a better way to alter mapstraction to provide this functionality and hide the internal methods? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100224/c9fea797/attachment.htm>
I just found an couple of issues with the implementation of the map initialisation. 1) Using microsoft maps the addLargeControls or addSmallControls have no effect. This is because the internal call to SetDashboardsize must be called before the proprietary ''loadmap'' is called. It is currently impossible to call the addLargeControls before the loadmap call as the mapstraction constructor has not returned before loadmap is called. 2) The onload event cannot have any handlers added in client code as this is fired before the mapstraction constructor returns and you have access to the object to addHandlers to the onload event. I think these can be resolved by spliting the contruction of the mapstraction object and the initialization of the map and the loading of the map. There is currently a feature that allows call to be deferred, although I can''t find examples of use of this in use, but there essentially needs to be 3 phases where the public map methods are valid. pre creation of proprietary map object. ( passed in to constructor ) between creation of the proprietary map object and actual loading of the map. post loading of the proprietary map object. the application code ought to be in the following steps. mapstraction = new mxn.Mapstraction(''map_canvas'',null,true); new mxn.Mapstraction(''map_canvas'',null,true); mapstraction.setOption("enableDoubleClickZoom", true); mapstraction.setOption("enableScrollWheelZoom", true); mapstraction.setOption("enableDragging", true); "enableDoubleClickZoom", true); mapstraction.setOption("enableScrollWheelZoom", true); mapstraction.setOption("enableDragging", true); "enableScrollWheelZoom", true); mapstraction.setOption("enableDragging", true); "enableDragging", true); mapstraction.setCenterAndZoom(..., ...); mapstraction.setMapType(mxn.Mapstraction.ROAD ); mapstraction.setMapType(mxn.Mapstraction.ROAD ); mapstraction.addControls({ pan: true, zoom: ''large'' || ''small'', overview: true, scale: true, map_type: true }); true, zoom: ''large'' || ''small'', overview: true, scale: true, map_type: true }); mapstraction.onload.addHandler = function (){ // do post load items. }; mapstraction.loadMap(); // this would be a new method. The init methods would need to call deferred methods at the pre/between/post If the methods could be deffered to the correct phase based on the proprietary implementation then the above application code would be possible. What are the thoughts on this? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100226/4a52d99a/attachment.htm>