Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9332] iOS: Map - Add centerOffset property to Ti.Map.Annotation

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-02T22:51:53.000+0000
Affected Version/sRelease 2.1.0
Fix Version/s2013 Sprint 14, 2013 Sprint 14 API, Release 3.1.2, Release 3.2.0
ComponentsiOS
Labelsmodule_map, qe-testadded
ReporterJose Carlos Andreu
AssigneeVishal Duggal
Created2012-05-31T11:44:04.000+0000
Updated2013-07-29T09:29:16.000+0000

Description

Add centerOffset property to a custom annotation to be able to set a x & y offset to the image of the annotation. Right now the center of the annotation is the center of the image size. This makes that some images appear not to be in their proper place at certain zoom levels. Reference to official documentation: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40008207 I have already coded the feature and I open this ticket in order to get the pull request accepted.

Comments

  1. Jose Carlos Andreu 2012-06-01

    I asked for a pull request: https://github.com/appcelerator/titanium_mobile/pull/2304
  2. Jose Carlos Andreu 2012-06-01

    I provide a simple test case to check it's working. When centerOffset is used the bottom end of the pin should be in the (0,0). I added the route to have some reference to check that the annotation is being moved when using the property.
       var win = Ti.UI.createWindow({});
       
       var mapView = Ti.Map.createView({
           height : '100%',
           width : '100%',
           mapType : Titanium.Map.STANDARD_TYPE,
       });
       
       var route = {
           color : "#000000",
           name : "route",
           points : [{latitude: 0, longitude: 0},{latitude: 30, longitude: 30}],
           width : 12
       };
       mapView.addRoute(route);
       
       var annotation0 = Ti.Map.createAnnotation({
           latitude: 0,
           longitude: 0,
           image: "image.png",
           title: "pin",
           //centerOffset: {x: 0, y: -24}
       });
       //This also works
       annotation0.setCenterOffset({x: 0, y: -24});
       
       mapView.addAnnotation(annotation0);
       win.add(mapView);
       win.open();
       
  3. Neeraj Gupta 2012-06-01

    @Jose - we will get to this PR shortly.
  4. Jose Carlos Andreu 2012-06-20

    I updated the code in github. No one is assigned at the moment. Do I have to notify someone?
  5. Neeraj Gupta 2012-06-20

    @Jose - we are in the middle of a release (2.1.0) and hence the delay. We will get to this PR next week.
  6. Julian Fraser 2013-03-05

    Any update on this? It's a fairly minor mod. This functionality is a relative necessity for anyone utilizing custom annotation images. The only current workaround is to create a pin image with 50% additional area transparent to give the appearance of the annotation in the correct position.
  7. John Josef 2013-04-04

    I have corrected this for v3.0.2 and have it working and verified on iOS. @Julian you can copy these files to your own SDK on your local machine. (Usually located at ~/Library/Application Support/Titanium/mobilesdk/osx//iphone/Classes) https://github.com/appcelerator/titanium_mobile/pull/4074
  8. Vishal Duggal 2013-07-02

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/4433
  9. Vishal Duggal 2013-07-02

    Test Case
       var win = Titanium.UI.createWindow();
       
       var mountainView = Titanium.Map.createAnnotation({
           latitude:37.390749,
           longitude:-122.081651,
           title:"Appcelerator Headquarters",
           subtitle:'Mountain View, CA',
           pincolor:Titanium.Map.ANNOTATION_RED,
           animate:true,
           leftButton: 'images/appcelerator_small.png',
           myid:1 // Custom property to uniquely identify this annotation.
       });
       
       var mapview = Titanium.Map.createView({
           mapType: Titanium.Map.STANDARD_TYPE,
           region: {latitude:37.390749, longitude:-122.081651,
                   latitudeDelta:0.01, longitudeDelta:0.01},
           animate:true,
           regionFit:true,
           userLocation:true,
           annotations:[mountainView]
       });
       
       var container1 = Ti.UI.createView({
           height:Ti.UI.SIZE,
           top:0
       })
       
       var container2 = Ti.UI.createView({
           height:Ti.UI.SIZE,
           bottom:0
       })
       
       
       
       win.add(mapview);
       
       win.add(container1);
       win.add(container2);
       
       var b1 = Ti.UI.createButton({
           title:'OFFSET 0,0',
           left:0
       })
       
       var b2 = Ti.UI.createButton({
           title:'OFFSET 0,24',
           right:0
       })
       
       var b3 = Ti.UI.createButton({
           title:'OFFSET 0,-24',
           left:0
       })
       
       var b4 = Ti.UI.createButton({
           title:'OFFSET -24,24',
           right:0
       })
       
       container1.add(b1);
       container1.add(b2);
       
       container2.add(b3);
       container2.add(b4);
       
       b1.addEventListener('click',function(e){
           Ti.API.info('SET CENTEROFFSET WITH PROP TO 0,0');
           mountainView.centerOffset = {x:0,y:0};
       })
       
       b2.addEventListener('click',function(e){
           Ti.API.info('SET CENTEROFFSET WITH PROP TO 0,24');
           mountainView.centerOffset = {x:0,y:24};
       })
       
       b3.addEventListener('click',function(e){
           Ti.API.info('SET CENTEROFFSET WITH METHOD TO 0,-24');
           mountainView.setCenterOffset({x:0,y:-24})
       })
       
       b4.addEventListener('click',function(e){
           Ti.API.info('SET CENTEROFFSET WITH METHOD TO -24,24');
           mountainView.setCenterOffset({x:-24,y:24})
       })
       
       
       win.open();
       
  10. Vishal Duggal 2013-07-25

    Backport to 3_1_X https://github.com/appcelerator/titanium_mobile/pull/4491
  11. Priya Agarwal 2013-07-29

    Updated label. Closing as Fixed. Verified with: Studio: 3.1.2.201307261628 SDK: 3.1.2.v20130726192706 acs:1.0.4 alloy:1.2.0-alpha titanium:3.1.1 titanium-code-processor:1.0.2-alpha OS: OSX 10.8.4 Device: ipad mini(v6.0) Xcode:4.6.3 centerOffset property to Ti.Map.Annotation working well.

JSON Source