titanium-mapbox
titanium-mapbox copied to clipboard
images for annotations
+1
@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.
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...
Hi,
Any luck with images as annotations?
Is there a new status? Maybe beta? :-)
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.
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.
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!
Hey @maikkley, how did you compile for 3.5.0+ (64-bit)?
@Xaynder Is there any chance you are able to share your work?
@nitrag
- I take the source code from github.
- Open the xcode project in xcode
- Update each of the target architectures to standard ( $(ARCHS_STANDARD) )
- Set the iOS Deployment Target to iOS 6.0 or newer
- Save the project
- Edit the manifest file in Titanium and add a line "architectures: armv7 arm64 i386 x86_64"
- set a new version number, e.g. 0.4.1
- compile and have fun :-)
Updating to 64 bit would make a great PR :)
@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
I would see, that i make a pull request on this weekend. :-)
Edit: Maybe tonight :-)
@maikkley
:'(
eagerly awaiting a PR for 64-bit support!
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 :-)
@adampax
See pull https://github.com/adampax/titanium-mapbox/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',
@nitrag awesome, will check out the PR, thanks
So, i hope that is the right way i create a PR :-) Let me know, if something is not working!
This is apparently in the most recent build although the images aren't showing for me.
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.