M
M
MakPET2016-04-30 21:50:11
JavaScript
MakPET, 2016-04-30 21:50:11

Why sets the marker in the right place?

does not work 'map.setPosition(new plugin.google.maps.LatLng(40.165282,44.324674));

document.addEventListener("deviceready", function() {
      var mapDiv = document.getElementById("map_canvas");

      function setMyPosition(position){
        var MyPos = new plugin.google.maps.LatLng(position.coords.latitude,position.coords.longitude);
        map = plugin.google.maps.Map.getMap(mapDiv, {
          'camera': {
            'latLng': MyPos,
            'zoom': 17
          }
        });
        map.setPosition(new plugin.google.maps.LatLng(40.165282,44.324674));

        map.addEventListener(plugin.google.maps.event.MAP_READY, function() {
          map.addMarker({
            'position': MyPos,
            'title': "Its me!"
          }, function(marker) {
                marker.showInfoWindow()

          });
          var button = document.getElementById("button");
          button.addEventListener("click", onBtnClicked, false);

        });

          function onBtnClicked() {
            map.showDialog();
          }
      }

      function onSuccess(position){
        // alert(map)
          document.getElementById('lat').innerHTML = position.coords.latitude;
          document.getElementById('log').innerHTML = position.coords.longitude;
           setMyPosition(position);

       };
       function onSuccessss(position) {
               var element = document.getElementById('element');
               element.innerHTML = '';
               element.innerHTML = 'Latitude: '  + position.coords.latitude      + '<br />' +
                                   'Longitude: ' + position.coords.longitude     + '<br />' +
                                   '<hr />'      + element.innerHTML;

           }
       function onError(error) {
             alert('code: '    + error.code    + '\n' +
                   'message: ' + error.message + '\n');
         }
    var options = { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true };
    var asa = navigator.geolocation.getCurrentPosition(onSuccess,onError,options)
    var sas = navigator.geolocation.watchPosition(onSuccessss,onError,options)
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question