Draw on the map

5 posts, 0 answers
  1. Scott
    Scott avatar
    14 posts
    Member since:
    Nov 2011

    Posted 08 Jun 2015 Link to this post

    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.
  2. Scott
    Scott avatar
    14 posts
    Member since:
    Nov 2011

    Posted 09 Jun 2015 in reply to Scott Link to this post

    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.

     

  3. T. Tsonev
    Admin
    T. Tsonev avatar
    2830 posts

    Posted 10 Jun 2015 Link to this post

    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
  4. Matt
    Matt avatar
    12 posts
    Member since:
    Jun 2014

    Posted 10 May in reply to T. Tsonev Link to this post

    Did the ability to draw get accepted into the Map component?
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2469 posts

    Posted 12 May Link to this post

    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.
Back to Top