2014-09-30 16 views
0

我正在使用以下函數在telerik appbuilder中使用kendo ui顯示地圖。如您所見,我已爲此分配了靜態緯度&經度。 請使用kendo ui提出一些獲取經緯度的方法。 我想將經度和緯度值傳遞給createMap(x,y)函數。在telerik appbuilder中使用Kendo-ui獲取緯度經度

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 
           }); 

}

回答

0

從Apache的科爾多瓦文檔:

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'); 
}