ThinkGeo.com    |     Documentation    |     Premium Support

Distance calculation and other Issues

1. In the version 3.02 it seems that the Map.GetWorldDistanceFromScreenPoints is returning bad values,


could you please check these values, I had an extent of 200km on the map did two points that were the width of the map apart in pixels and got around 20km.  Also it would be useful to just add a GetWorldDistance function on the map as this would be handy.


 


2. Also i realize that in your Conversion Class we can't convert from decimal degrees to meters which is always required at some point.


 


3. Also I really miss the CustomZoomLevels on the ZoomLevel as it was very easy to use than to have to know how to line up the zoom levels to get what you want.  Also there is not function that tells if a layer is visible to the user based on the ZoomLevelSet you have set up.


 


4. Your implementation of the MapClick needs some tweaking as the click event is raised after a drag pan action which can be annoying when using the popups on click.


 


Here is some javascript that avoids it


 


OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {

            defaultHandlerOptions: {

                'single': true,

                'double': false,

                'pixelTolerance': 0,

                'stopSingle': false,

                'stopDouble': false

            },



            initialize: function(options) {

                this.handlerOptions = OpenLayers.Util.extend(

                        {}, this.defaultHandlerOptions

                    );

                OpenLayers.Control.prototype.initialize.apply(

                        this, arguments

                    );

                this.handler = new OpenLayers.Handler.Click(

                        this, {

                            'click': this.trigger

                        }, this.handlerOptions

                    );

            },



            trigger: function(e) {



               PUT YOUR CODE TO CALL THE MAPCLICK POSTBACK HERE



            }



        });


 


var parser = mapParserMap1;


map = parser.map;







var click = new OpenLayers.Control.Click();

map.addControl(click);

click.activate();

 



Thank you for the post!  Please see my comments below on each item.


1. I wasn't able to recreate this issue, can you check to make sure your Map1.MapUnit property is set correctly on the Map Control.  If this is set wrong will not calculate the distance correctly.    If it is set correctly can you provide more information or a sample app so we can try to recreate it here?


 


2. This is a great idea and has been added to are enhancement database.


 


3. This is also a great idea and has been added to our enhancement database.


 


4. Thanks for the code on this one, we have added it to our issues database and will try to find a better solution for a future release.


Please keep posting any findings or other enhancements you would like to see.


Thanks!