Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Get annotation position

When an annotation right button is clicked a mapview click gets fired it is supposed to send the X & Y of the click. It doesn't. I have tried checking the e.x and e.y, e.annotation.left, e.source.x, e.globalPoint.x and other combinations with no luck.

What I'm trying to do is create a popover where the annotation is when the right button is clicked. It can be done on the iPad in the Google Maps app. Do a search and click on the right button and it will hide the annotation flyout and replace it with a popover.

Anyone have any suggestions?

— asked September 27th 2010 by John McKnight
0 Comments

3 Answers

  • I ended up writing code to convert the lat/lng of the annotation to a pixel location within the mapview and then creating a popover at that position. If anyone else needs to do something like that, let me know and I can post some sample code.

    — answered September 29th 2010 by John McKnight
    permalink
    7 Comments
    • Yes please, I would like to know how to do this.

      — commented December 14th 2010 by Rubin Singh
    • can I get that sample code as well?
      Thanks!

      — commented September 2nd 2011 by Edwin Huertas
    • Is the sample code posted somewhere?

      — commented October 9th 2011 by George Hess
    • Any code for this would be greatly appreciated!!

      — commented October 24th 2011 by Brian Wells
    • John can you please share the code! pleease!

      — commented October 26th 2011 by Andrea Phillips
    • check out this post: http://developer.appcelerator.com/question/32291/attaching-a-popover-to-a-map-annotation-title

      it has a working solution

      — commented October 26th 2011 by Chris Metropolis
    • This will work:

      var annotation_x = (((e.annotation.longitude-this.actualRegion.longitude)/(this.actualRegion.longitudeDelta/mapview.getWidth())) + (mapview.getWidth()/2));
      
      var annotation_y = (((e.annotation.latitude-this.actualRegion.latitude)/(-this.actualRegion.latitudeDelta/mapview.getHeight())) + (mapview.getHeight()/2));
      
      • "mapview.actualRegion" has to be updated!
      mapview.addEventListener('regionChanged', function(e) {
              mapview.actualRegion = e;
      });
      

      — commented October 25th 2012 by Joao Silva
  • YES YES YES I would love to have this code please…trying to do the same myself!!!

    — answered July 19th 2011 by Taylor Jones
    permalink
    0 Comments
  • this might help: http://developer.appcelerator.com/question/32291/attaching-a-popover-to-a-map-annotation-title

    — answered October 21st 2011 by Chris Metropolis
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.