Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapa cortado cuando cambio la orientación del celular. #92

Open
mauricioLopezRamirez opened this issue Jun 13, 2018 · 6 comments
Open

Comments

@mauricioLopezRamirez
Copy link

screenshot_20180613-155841
screenshot_20180613-155836

@risinghero
Copy link
Contributor

Hi @mauricioLopezRamirez. Unfortunately I understand Spanish only with Google translate. But I hope that you understand English. Add orientation cordova plugin. Subscribe to orientation change event and recreate map. Like this (I haven't tested):
screen.orientation.addEventListener('change', function(){ Mapbox.hide(); Mapbox.show(yourOptions); });

@mauricioLopezRamirez
Copy link
Author

mauricioLopezRamirez commented Jun 14, 2018

@risinghero gracias por tu respuesta, lo e hecho sin plugin, solo utilice javascript lo cual detecta el cambio de orientación pero no ha funcionado el siguiente código. Que otra opción propones:

  window.addEventListener("orientationchange", function() {

Mapbox.hide();
showMap();

});

@risinghero
Copy link
Contributor

@mauricioLopezRamirez please check with debugger that event "orientationchange" works. There can be some problems with it.

@mauricioLopezRamirez
Copy link
Author

@risinghero si funciona, e puesto un alert para que me verifique que si se cambio de orientación y si cambia.

@risinghero
Copy link
Contributor

@mauricioLopezRamirez to further help you I need simple example reproducing this issue. Can you create one? Just Map+subscription to event so i can test it on my pc.

@mauricioLopezRamirez
Copy link
Author

mauricioLopezRamirez commented Jun 14, 2018

ok @risinghero este es mi codigo del index.html

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width">
    <script type="text/javascript" src="cordova.js"></script>
   

  </head>
  <body onload="onLoad()">

  
<script>
  function onLoad() {

     document.addEventListener("deviceready", onDeviceReady, false);

 }

 function onDeviceReady() {
    showMap();
 }


  var zoom = 12;


  function setTilt() {
    Mapbox.setTilt({
      pitch: 45,
      duration: 4500
    });
  }


 window.addEventListener("orientationchange", function() {

Mapbox.hide();
showMap();

});

  function showMap() {

    Mapbox.show({
              style: 'emerald',
              margins: {
                'left': 0,
                'right': 0,
                'top': 0,
                'bottom': 0
              },
              center: {
                
                lat: 3.4210196,
                lng: -76.5201787
              },
              zoomLevel: zoom, // 0 (the entire world) to 20, default 10
              showUserLocation: true, // default false
              hideAttribution: true, // default false
              hideLogo: true, // default false
              hideCompass: false, // default false
              disableRotation: false, // default false
              disableScroll: false, // default false
              disableTilt: false, // default false
              disableZoom: false, // default false
              disablePitch: false, // default false
              markers: [
                {  
                  'lat': 3.4356455,
                  'lng': -76.5281464,
                  'title': 'CALLE 13 CON CARRERA 23',
                  'subtitle': 'Sentido: SUR-NORTE\nZona: CENTRO'
                }
              ]
            },
            function (result) {
              console.log(JSON.stringify(result));
              // let's add a callback for these markers - invoked when the callout is tapped (Android) or the (i) icon in the marker callout (iOS)
              Mapbox.addMarkerCallback(function (selectedMarker) {
               // alert("Marker selected: " + JSON.stringify(selectedMarker));
              });
              // let's add callbacks for region changing
              //
              // - invoked when the map is about to moved (animated or not).
              Mapbox.onRegionWillChange(function(centerCoordinates) {
                console.log("Map will move from: ", centerCoordinates);
              });
              // - invoked at each tick (so 60 per second) when the map moves. So don't do any heavy computing here.
              Mapbox.onRegionIsChanging(function(centerCoordinates){
                console.log("New map center is: ", centerCoordinates);
              });
              // - invoked after the map has moved (animated or not).
              Mapbox.onRegionDidChange(function(centerCoordinates) {
                console.log("Map as finished to move to : ", centerCoordinates);
              });
            },
            function (error) {
              alert(error);
            }
    )
  }

</script>

  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants