如何在混合移动应用程序中使用skobbler地图

时间:2016-09-01 12:15:08

标签: dictionary ionic-framework hybrid-mobile-app

你能帮我在离子型应用程序中实现Skobbler地图吗?

感谢

1 个答案:

答案 0 :(得分:0)

by using following code i can draw map.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script src="js/skobbler-2.0.js"></script>
<style>
#map {
    height: 500px;
}
</style>
<div id="map"></div>
<script>
   function initMap() {
         navigator.geolocation.getCurrentPosition(function(position) {
           var pos = {
             lat: position.coords.latitude,
             lng: position.coords.longitude
           };
            console.log(pos.lat + "/" +pos.lng);
                    //  alert(pos.lat + "/" +pos.lng);
                        mytest(pos.lat,pos.lng);
       });

     }
window.setInterval(function(){
initMap()
}, 1000);
var mymap = '';
var marker = '';
function mytest(lat,long)
{
    if(mymap == '' || marker == '')
    {
        mymap = L.skobbler.map('map', {
                apiKey: 'API_KEY',
                mapStyle: 'day',
                bicycleLanes: true,
                onewayArrows: true,
                pois: 'all',
                primaryLanguage: 'en',
                fallbackLanguage: 'en',
                mapLabels: 'localNaming',
                retinaDisplay: 'auto',

                zoomControl: true,
                zoomControlPosition: 'top-left',
                center: [lat,long],
                zoom: 18,
        });
        marker = L.marker([lat,long]).addTo(mymap);
    }
    else
    {
        mymap.center = [lat,long];
        marker.remove(marker);
        marker = L.marker([lat,long]).addTo(mymap);
    }
}
</script>
</head>
<body>
</body>
</html>