We are wishing to replace a couple google maps with the Telerik map control with openstreet tiles. In most cases this has been a straight forward effort.
In one instance, we have a pin that we can drag and drop on the map to identify a location. Is this possible with the Telerik control? If so, can you provide some sample code using openstreet that includes also capturing the lat/lon of the dropped pin?
Thanks in advance
6 Answers, 1 is accepted
Here is a code sample where you can see the required functionality implementation:
Also review the following online code sample:
Thank you for the reply and great sample. I am having one small issue. When I drop the pin on a location, it settles down and to the right about an inch down and 3 inches to the right from where I intend to drop it
I believe the issue is in the following code, specifically map.viewToLocation. I have not been able to locate any documentation on this.
var loc = map.viewToLocation([args.x.client, args.y.client]);
Any direction would be great...
I also noticed that when the marker is dropped it is moved slightly down and to the right. The only solution with I currently found is the following code:
var loc = map.viewToLocation([args.x.client - 8, args.y.client - 8]);
Please inform me if this does not fix the problem for you.
To achieve a "correction", my adjustment is quite significante compared to yours... below is my adjusted code to get the pin to dop where my cursor is...
var loc = map.viewToLocation([args.x.client - 196, args.y.client - 80]);
My concern of course is why the difference in our experiences (such a difference in correction)... I tested locally on Chrome, Firefox, Safari and IE (all current builds). IE, the drag does not work at all, the other browsers, respond consistently. I will post to a staging site soon and see if I get the proper correction, but the fact that we need to correct with different numbers causes me concern that our users will experience different behavior.
Is this correction a work-around until your team can dive deeper into the problem?
- UPDATE -
The correction required appears to be related to the size of the map.
Map1 is sized at 708h, no width set and the correction is var loc = map.viewToLocation([args.x.client - 196, args.y.client - 80]);
Map2 is sized at 456h x 890w and correction is var loc = map.viewToLocation([args.x.client - 20, args.y.client - 60]);
Indeed, such a behavior exists and it is relevant to how the browser retrieves the cursor position withing the drop event's arguments.
I am afraid, there is no more suitable fix for that. As you can see this is also more relevant to the Kendo Map and you can put your concern in Kendo User Voice portal, so to be further reviewed and discussed by the map's developers.