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

Draw on the map

4 Answers 129 Views
Map
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 08 Jun 2015, 02:50 PM
Is it possible to draw shapes on the map with a mouse?  I do not see mouse events exposed for the map or shape layer.

4 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 09 Jun 2015, 11:42 AM

Here is some code I have been trying,

 

$("#map").mousedown(mapMouseDown);
$("#map").mousemove(mapMouseMove);
$("#map").mouseup(mapMouseUp);

var _drawing = false;
var _currentShape = null;
var _shapeData = new Array(0);
var _map = $("#map").data("kendoMap");
var _shapeLayer = _map.layers[2];
var _lineShapeFactory = new LineShapeFactory();
var _polygonShapeFactory = new PolygonShapeFactory();

var _counter = 0;

function mapMouseDown(e) {
    
    var location = _map.eventToLocation(e);

    _currentShape = new _lineShapeFactory.CreateNew();

    _currentShape.coordinates.push(new Array(location.lat, location.lng));

    _currentShape.coordinates.push(new Array(location.lat, location.lng));

    _shapeData.push(_currentShape);

    _shapeLayer.datasource = _shapeData;

    _drawing = true;

    e.stopPropagation();

    var foo = null;
}

function mapMouseMove(e) {

    if (_drawing == false) {
        return;
    }

    var location = _map.eventToLocation(e);

    if (_currentShape.type == "Linestring") {
        _currentShape.coordinates[1] = new Array(location.lat, location.lng);
    }

    var test = _shapeData;

    e.stopPropagation();

    if (counter == 100) {
        var foo = null;
    }

    counter++;
}

function mapMouseUp(e) {
    _drawing = false;

    e.stopPropagation();
}

function LineShapeFactory() {
    this.CreateNew = function () {
        var newLineString = {
            "type": "Linestring",
            "coordinates": new Array(0)
        };

        return newLineString;
    }
}

The map is named "map", and it has in this order a tile layer, a marker layer, and a shape layer.

 

0
T. Tsonev
Telerik team
answered on 10 Jun 2015, 08:11 AM
Hi,

Using the shape layer as a drawing surface is an interesting idea. It makes possible to persist the changes in a standard format. We'll consider it as a full-blown feature.

Please, file a request for this feature on our UserVoice portal if you have minute.
This will help us gauge the overall interest and prioritize.

Regards,
T. Tsonev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Matt
Top achievements
Rank 1
Veteran
answered on 10 May 2020, 09:39 AM
Did the ability to draw get accepted into the Map component?
0
Viktor Tachev
Telerik team
answered on 12 May 2020, 03:44 PM

Hello Matt,

 

I am afraid that such functionality is not available out of the box. Furthermore, there is no request for it in our feedback portal.

https://feedback.telerik.com/kendo-jquery-ui

 

If you would like to request the feature please log an item in the portal. We prioritize the requests based on the customer demand and the impact they would have for a given component.

 

Regards,
Viktor Tachev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Map
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
T. Tsonev
Telerik team
Matt
Top achievements
Rank 1
Veteran
Viktor Tachev
Telerik team
Share this question
or