Closed bitfabrikken closed 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.
@yozef You added the updateLocation
API, maybe it has kroll-/ main-thread issues? @bitfabrikken which thread are you running on?
@hansemannn how can I see that?
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.
@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
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 :-)
<property name="run-on-main-thread" type="bool">true</property>
in your tiapp.xml toplevel, that's it!
It's causing issues for me too with run-on-main-thread. I'll take your advice and check it out this weekend.
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.
I was working on it yesterday, trying to figure out the issue... I'll check the commit ;)
@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.
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);