Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

images for annotations #4

Open
adampax opened this issue Apr 5, 2014 · 21 comments
Open

images for annotations #4

adampax opened this issue Apr 5, 2014 · 21 comments

Comments

@adampax
Copy link
Owner

adampax commented Apr 5, 2014

No description provided.

@yozef
Copy link

yozef commented Apr 27, 2014

+1

@adampax
Copy link
Owner Author

adampax commented Apr 27, 2014

@yozef I spent some time last week looking into this, but ran into an issue with image size not getting handled properly when added to the callout. The Mapbox SDK is using a library called SMCallout to create the callouts. Maybe it is having an issue with the Ti Proxy view being passed to it.

@yozef
Copy link

yozef commented Apr 28, 2014

I may have to start implementing this module in the coming weeks for a released app, I'll try to take a look as well...

@Xaynder
Copy link

Xaynder commented Oct 25, 2014

Hi,

Any luck with images as annotations?

@maikkley
Copy link

maikkley commented Mar 9, 2015

Is there a new status? Maybe beta? :-)

@Xaynder
Copy link

Xaynder commented Mar 9, 2015

I made a HUGE workaround by actually removing the whole module and using Mapbox's JS API that I've implemented inside a webview. It allows me to use the whole API (including images for annotations) and still interact with titanium using Ti.App.fireEvent("app:eventName");

It works surprisingly well.

@maikkley
Copy link

Ok, thanks.
This will not work for me, because i have an offline map :-/ So i must implement a solution to set images on an offline map.

@maikkley
Copy link

For an annotation image, replace the function above in /Classes/ComPolancomediaMapboxView.m

- (RMMapLayer *)markerLayer:(RMMapView *)mapView userInfo:(NSDictionary *)userInfo
{
    //RMMarker *marker = [[RMMarker alloc] initWithMapBoxMarkerImage:nil tintColor:([TiUtils isIOS7OrGreater] ? mapView.tintColor : nil)];

    NSDictionary *args = [userInfo objectForKey:@"args"];
    RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:[TiUtils stringValue:[args objectForKey:@"imageUrl"]]] anchorPoint:CGPointMake(0.5, 1.0)];

    marker.canShowCallout = YES;

    return marker;
}

Note that you can now make something like this

        mapView.setAnnotation({
            latitude:xx.97080,
            longitude:xx.86068,
            title:'Title',
            subtitle: 'Subtitle',
            imageUrl:'images/test.png'
        });

Attention: You must paste the imageUrl without leading "/" :-)
have fun!

@nitrag
Copy link

nitrag commented Mar 12, 2015

Hey @maikkley, how did you compile for 3.5.0+ (64-bit)?

@type88
Copy link

type88 commented Mar 12, 2015

@Xaynder Is there any chance you are able to share your work?

@maikkley
Copy link

@nitrag

  1. I take the source code from github.
  2. Open the xcode project in xcode
  3. Update each of the target architectures to standard ( $(ARCHS_STANDARD) )
  4. Set the iOS Deployment Target to iOS 6.0 or newer
  5. Save the project
  6. Edit the manifest file in Titanium and add a line "architectures: armv7 arm64 i386 x86_64"
  7. set a new version number, e.g. 0.4.1
  8. compile and have fun :-)

@adampax
Copy link
Owner Author

adampax commented Mar 13, 2015

Updating to 64 bit would make a great PR :)

@nitrag
Copy link

nitrag commented Mar 13, 2015

@maikkley

Tried your steps exactly. Didn't work.

Did you let xcode update project to preferred settings?
Do you build for active architectures only?
Did you have to update mapbox-ios-sdk?
Did you change build.py?
Can you submit a PR for your working code? ;)


** BUILD FAILED **

The following build commands failed:

CompileC build/MapView.build/Release-iphoneos/MapView.build/Objects-normal/armv7/RMAbstractWebMapSource.o Map/RMAbstractWebMapSource.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

(1 failure)

xcodebuild failed

@maikkley
Copy link

I would see, that i make a pull request on this weekend. :-)

Edit: Maybe tonight :-)

@nitrag
Copy link

nitrag commented Mar 16, 2015

@maikkley

:'(

eagerly awaiting a PR for 64-bit support!

@maikkley
Copy link

Sorry, i have not configurated git in Titanium Studio. I am on the way, but it is the first time, that i use github to fork and make a pull request :-)

@nitrag
Copy link

nitrag commented Mar 17, 2015

@adampax

See pull #16

I made a PR, please test on your end but I think I've got everything updated and working!

Note that due to parity with the file.resolve(), you now need to add the mbtiles extension.

map: 'control-room.mbtiles',

@adampax
Copy link
Owner Author

adampax commented Mar 17, 2015

@nitrag awesome, will check out the PR, thanks

@maikkley
Copy link

So, i hope that is the right way i create a PR :-)
Let me know, if something is not working!

@gregpardo
Copy link

This is apparently in the most recent build although the images aren't showing for me.

@maikkley
Copy link

I have modified my module to much, that i can't upload it or make a PR.
But, my source code for images in that line:
https://github.com/adampax/titanium-mapbox/blob/master/Classes/ComPolancomediaMapboxView.m#L377

looks like:

    NSDictionary *args = [userInfo objectForKey:@"args"];
    NSString *url = [TiUtils stringValue:[args objectForKey:@"imageUrl"]];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent: url];
    CGFloat mySize = (CGFloat)[[TiUtils stringValue:[args objectForKey:@"imageSize"]] floatValue];
    CGSize rect = CGSizeMake(mySize,mySize);

    UIImage *img;

    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
        img = [self imageWithImage:[UIImage imageWithContentsOfFile:path] scaledToSize:rect];
    } else {
        img = [UIImage imageNamed:url];
    }
    RMMarker *marker = [[RMMarker alloc] initWithUIImage:img anchorPoint:CGPointMake(0.5f, 1.0f)];

and it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants