This is a migrated thread and some comments may be shown as answers.

Wrong location for marker on click

4 Answers 65 Views
Map
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 15 Mar 2019, 11:55 AM

After updating to the 2018.3.910-release the markers on the map seem to be placed quite a bit off from where I clicked with the mouse. 

(Attatched files show location of mouse click with a small red dot)

Both the 2018.3.910 release and the 2019.1.215 release causes the same error, but when i go back to 2017.1.228 everything seems to be OK.

 

Any idea on what can be done?

 

JavaScript for placing markers:

<script type="text/javascript">
        function SetRadMapMarker(eventArgs)
        {
            eventArgs.sender.markers.add(
            {
                location: eventArgs.location,                              
            });
        }
    </script>

RadMap

            <telerik:RadMap ID="RadMap1" runat="server" Zoom="17">
                <CenterSettings Latitude="42.650613" Longitude="23.379025"/>
                <LayersCollection>
                    <telerik:MapLayer Type="Tile" Subdomains="a,b,c"
                        UrlTemplate="https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"                                
                        Attribution="&copy; <a href='http://osm.org/copyright' title='OpenStreetMap contributors' target='_blank'>OpenStreetMap contributors</a>.">
                    </telerik:MapLayer>
                </LayersCollection>
            </telerik:RadMap>

4 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 20 Mar 2019, 08:11 AM
Hello Anders,

We are aware of such Marker positioning issues and we have logged it in our feedback portal: Map location is not correct in OnClick event arguments

Please check if the workaround suggested in the item would resolve the issue: 

kendo.dataviz.ui.Map.fn.eventOffset= function (e) {
    var point;
    var x;
    var y;
    var offset = this.element.offset();
  
    if (e.x || e.y) {
        var field = "location";
        x = e.x[field] - offset.left;
        y = e.y[field] - offset.top;
        point = new kendo.geometry.Point(x, y);
    } else {
        var event = e.originalEvent || e;
        x = valueOrDefault(event.pageX, event.clientX) - offset.left;
        y = valueOrDefault(event.pageY, event.clientY) - offset.top;
        point = new kendo.geometry.Point(x, y);
    }
  
    return point;
}

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Anders
Top achievements
Rank 1
answered on 21 Mar 2019, 01:31 PM

Hi Peter!

Thanks for the reply. I tested the workaround and managed to get the marker at the correct location.

However, now I lost the ability to use the mouse wheel to zoom on the map. Removing the suggested javascript code makes the zooming with mouse wheel work again.

(Regular zoom with double click works, and using the +/--buttons works as well.)

 

Best regards,

Anders

0
Accepted
Peter Milchev
Telerik team
answered on 26 Mar 2019, 09:01 AM
Hello Anders,

The Zoom does not work because there is a JavaScript error caused by the fact that the definition of the valueOrDefault function. The following updated script should not cause any errors: 

kendo.dataviz.ui.Map.fn.eventOffset = function (e) {
    var point;
    var x;
    var y;
    var offset = this.element.offset();
 
    if (e.x || e.y) {
        var field = "location";
        x = e.x[field] - offset.left;
        y = e.y[field] - offset.top;
        point = new kendo.geometry.Point(x, y);
    } else {
        var event = e.originalEvent || e;
        x = kendo.drawing.util.valueOrDefault(event.pageX, event.clientX) - offset.left;
        y = kendo.drawing.util.valueOrDefault(event.pageY, event.clientY) - offset.top;
        point = new kendo.geometry.Point(x, y);
    }
 
    return point;
}


Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Anders
Top achievements
Rank 1
answered on 26 Mar 2019, 02:45 PM

It works fine :)

Thanks.

Tags
Map
Asked by
Anders
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Anders
Top achievements
Rank 1
Share this question
or