js: [MapKit] Rotation is not available.

Hi,


I've bulit an app for iOS and I can show, zoom and rotate the maps in it. Now, I am trying to do the same with PyQt5. I am able to show the maps, change location, zoom into a region, and enable / disable the view of the compass. I just cannot rotate the map: I receive the error message "js: [MapKit] Rotation is not available."


The mapkit js documentation refers to the property "isRotationAvailable" and the method "setRotationAnimated" (https://developer.apple.com/documentation/mapkitjs/mapkit/map/2991323-setrotationanimated)


Here is the html code I am using:


<script>
  mapkit.init({
  authorizationCallback: function(done) {
  done(".myToken");},
  language: "en"
  });

  var map = new mapkit.Map("map");
  // Hide the zoom controls.
  map.showsZoomControl = true;
  map.isZoomEnabled = true;
  map.isRotationAvailabe = true;

  function set_zoom(latitude, longitude, span_lat, span_lon) {

    var newCenter = new mapkit.Coordinate(latitude, longitude);
    var span = new mapkit.CoordinateSpan(span_lat, span_lat); 
    var region = new mapkit.CoordinateRegion(newCenter, span);
    var zoomRange = new mapkit.CameraZoomRange(250, 2000);
    map.setRegionAnimated(region);

    map.cameraZoomRange = zoomRange;

    // Either two of these lines raise the warning message
    map.rotation = 90;
    map.setRotationAnimated(90);
  }

</script>


Am I missing something really basic here or is this feature still not supported for mapkits js?


Thanks a lot

Accepted Reply

`isRotationAvailable` is a read-only property that lets you know whether rotation is available. Rotation is not available when the map is displayed with image tiles (for example, in browsers that don't support WebGL).


Can you rotate this map with a gesture, or with the compass control? When you are able to rotate the map in these ways, isRotationAvailable should return true. FWIW I tried out your code minus setting the region (since I don't know the coordinates or span that you're using) and it worked for me.

Replies

There is a typo in the script. "isRotationAvailabe" should be "isRotationEnabled". This error, however, does not change the behavior of the error. Once corrected, I still keep receiving the error message: ""js: [MapKit] Rotation is not available."

`isRotationAvailable` is a read-only property that lets you know whether rotation is available. Rotation is not available when the map is displayed with image tiles (for example, in browsers that don't support WebGL).


Can you rotate this map with a gesture, or with the compass control? When you are able to rotate the map in these ways, isRotationAvailable should return true. FWIW I tried out your code minus setting the region (since I don't know the coordinates or span that you're using) and it worked for me.

Hi,


Thanks for the answer. The problem, indeed, was with WebGL. When I launched my application from a conda environment, OpenGL was not properly loaded.


I downloaded from StackOverflow this code and used it to check the status of WebGL in my MacOS:


import os, sys
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets


if __name__ == '__main__':
  app = QtWidgets.QApplication(sys.argv)

  # app.setAttribute(QtCore.Qt.AA_UseOpenGLES) # nothing happens, you can comment it out

  view = QtWebEngineWidgets.QWebEngineView()

  view.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.WebGLEnabled, True) # does not help too = (((

  view.load(QtCore.QUrl("http://webglreport.com/?v=2"))

  view.show()

  sys.exit(app.exec_())


When I leave the conda environnment, then WebGL 1 works in my application (WegGL 2 is not available). WebGL 1 seems to be enough for my application, now it rotates the map and shows the compass.


Thanks a lot

Vicki,


Thanks for that information. I'm running into the issue where it says rotation is not enabled. But deleting the browser's cache and reloading normally fixes it. Do you know why sometimes it would work and other times it wouldn't? Is there other factors that could cause mapkit to revert to image tiles? This is behind a pretty strict network only, works great outside of it.