hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

annotation.updateLocation not working #62

Closed bitfabrikken closed 7 years ago

bitfabrikken commented 7 years ago

The follow example should move the annotation after 5 seconds - it doesn't :)

(sorry can't get code tags to work this time)

var win = Ti.UI.createWindow({}); win.open();

var maps = require("ti.googlemaps"); maps.setAPIKey("");

var mapView = maps.createView({ mapType: maps.MAP_TYPE_TERRAIN, indoorEnabled: true, indoorPicker: false, compassButton: true, myLocationButton: true, myLocationEnabled: true, region: { latitude: 37.368122, longitude: -121.913653, zoom: 0 } }); win.add(mapView);

var annotation = maps.createAnnotation({ latitude: 37.368122, longitude: -121.913653, title: "drag me", subtitle: "please drag me", draggable: true });

mapView.addAnnotation(annotation);

setTimeout(function(){ Ti.API.warn("moving annotation to -50, 50!"); annotation.updateLocation({latitude: -50, longitude: 50 }); },5000);

yozef commented 7 years ago

I had this same issue. I think it's the way the new addAnnotation works.

What I have done is removed the annotation, and re-added it.

example:


mapView.addAnnotation(myAnn);
setTimeout(function(){
  mapView.removeAnnotation(myAnn); // remove it
  myAnn = maps.createAnnotation({ ...}); // recreate it
  mapView.addAnnotation(myAnn); // re-add it
},5000);

It know it's not the ideal solution.
hansemannn commented 7 years ago

@yozef You added the updateLocation API, maybe it has kroll-/ main-thread issues? @bitfabrikken which thread are you running on?

bitfabrikken commented 7 years ago

@hansemannn how can I see that?

hansemannn commented 7 years ago

If you have the run-on-main-thread property in your tiapp.xml, you're running on main-thread, otherwise on kroll-thread. I'm usually testing with main-thread.

bitfabrikken commented 7 years ago

@hansemann, @yozef: Ok I must be running on kroll-thread then, as I have no run-on-main-thread in tiapp.xml - not for my app, nor for tishadow

hansemannn commented 7 years ago

Bonus tip: Try to upgrade sooner than later and report possible issues to the Titanium JIRA. We are currently actively fixing outstanding issues and will likely make it the default in a few versions. So the more people test it already, the more feedback we get for possible use-cases we didn't catch so far :-)

hansemannn commented 7 years ago

<property name="run-on-main-thread" type="bool">true</property> in your tiapp.xml toplevel, that's it!

yozef commented 7 years ago

It's causing issues for me too with run-on-main-thread. I'll take your advice and check it out this weekend.

hansemannn commented 7 years ago

Huii, fixed it in https://github.com/hansemannn/ti.googlemaps/pull/58/commits/82a2c18deecac44a4244dfd22707e0c6ab460527! If @yozef can review the PR, the fix will be available this evening, together with the clustering etc.

yozef commented 7 years ago

I was working on it yesterday, trying to figure out the issue... I'll check the commit ;)

hansemannn commented 7 years ago

@yozef Basically, the issue was in the first line, where the arguments have been passed incorrectly to the main-thread. Replaced that line and added the (optional) animation properties.