0

I am using below function to display a map using kendo ui in telerik appbuilder. As you see, I have assigned static latitude & longitude to this. Please suggest some way to fetch lat long using kendo ui. I want to pass the latitude and longitude values to createMap(x,y) function.

 function createMap(x,y) {
 console.log("createmap");
   // console.log("x=" + x + "  " +  "y=" + y);
 var ds = [
           { "shape": "green", "location": [30.667936 ,76.732688] }, 
          ];
// 30.710458600000000000    30.657762   
// 76.703347099999970000    76.740835

$("#map, #addAddFav").kendoMap({
                                   center: [30.667936, 76.732688],
                                   zoom: 10,
                                   layers: [{
                                               type: "tile",
                                               urlTemplate: "http://#= subdomain #.tile2.opencyclemap.org/transport/#= zoom #/#= x #/#= y #.png",
                                               subdomains: ["a", "b", "c"],
                                               attribution: "&copy; <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>." +
                                                            "Tiles courtesy of <a href='http://www.opencyclemap.org/'>Andy Allan</a>" 

                                           }, 

                                            {
                                               type: "marker",
                                             /*  dataSource: {
                                                           transport: {
                                                                           read: {
                                                                                   url: "map/store-locations.json",
                                                                                   dataType: "json"
                                                                                 }
                                                                       }
                                                            },*/

                                               // locationField: "latlng",
                                               // titleField: "name"


                                           }

                                    ],

                                     markers:  ds,
                                    click: onMapMarkerClick,
                                    shapeClick: onShapeClick,
                                    shapeCreated: onShapeCreated
                               });

}

vicky
  • 241
  • 1
  • 3
  • 12

1 Answers1

0

From the Apache Cordova docs:

navigator.geolocation.getCurrentPosition(onSuccess, onError);

// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function(position) {
    alert('Latitude: '          + position.coords.latitude          + '\n' +
          'Longitude: '         + position.coords.longitude         + '\n' +
          'Altitude: '          + position.coords.altitude          + '\n' +
          'Accuracy: '          + position.coords.accuracy          + '\n' +
          'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
          'Heading: '           + position.coords.heading           + '\n' +
          'Speed: '             + position.coords.speed             + '\n' +
          'Timestamp: '         + position.timestamp                + '\n');
};

// onError Callback receives a PositionError object
//
function onError(error) {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
}
Rob Lauer
  • 3,075
  • 1
  • 32
  • 44