I want to draw a route using google api please suggest me is there any google api is available for drawing route between 2 latitude and Longitude.
NSString * urlString = nil;
urlString = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=%f,%f&daddr=%#",12.58, 77.35, [NSString stringWithFormat:#"%#,%#,%#",[detailInfoDict valueForKey:#"address"],[detailInfoDict valueForKey:#"city"],[detailInfoDict valueForKey:#"state"]]];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]]
You can do using this way as well.
Step 1:
Add this Frameworks
Step 2: Imports these files into your View Controllers .h file
Step 3: Provide 2 Location's latitude and longitude in ViewControllers' .m file
OutPut:You will get output like this
Related
I'm new in developing iOS Apps.
I would like to use the built in core image filters in my app. But I don't know how I can use them. I have already created the "CISephiaTon" filter. Now I would like to create the "CIPhotoEffectTransfer" filter. But I don't know how I can do this =(
Does anybody knows a good tutorial or can give me one for applying core image filters in xcode 5?
This is the filter which I want to add. Could someone give me the code of this filter?
Hope someone can help me.
Observe the following code...
//First create a CIImage
UIImageOrientation originalOrientation = origim.imageOrientation;
data3 = UIImagePNGRepresentation(origim);
CIImage *result = [CIImage imageWithData:data3];
//Create the context
CIContext *context = [CIContext contextWithOptions:nil];
Apply the filter
CIFilter *colorControlsFilter = [CIFilter filterWithName:#"CIColorControls"];
[colorControlsFilter setDefaults];
[colorControlsFilter setValue:result forKey:#"inputImage"];
[colorControlsFilter setValue:[NSNumber numberWithFloat:slySlider1.value] forKey:#"inputSaturation"];
result = [colorControlsFilter valueForKey: #"outputImage"];
//Create CGImage with the original orientation, CIImage, and context.
CGImageRef imgRef = [context createCGImage:result fromRect:result.extent];
//Create the new UIImage from CGImage
theimage.image = [[UIImage alloc] initWithCGImage:imgRef scale:1.0 orientation:originalOrientation];
//Release CGImageRef
CGImageRelease(imgRef);
Good tutorial Beginning Core Image
I 've been trying to add a half circle to a map view using a custom MKOverlayPathView subclass and a custom class which confirms to but I cannot get anything to show up on the map view. I use a UIBezierPath to create the path for the circle, but no matter what I try, I cannot see my path...
Does anyone have an example program in which a UIBezierPath is being used as overlay?
Thank you!
Tim
Edit: Answer to Anna's question:
I can draw MKCircleViews without any problem, but I seem to struggle with custom subclasses for MKOVerlay(Path)View. The delegate is set, and an NSLog confirms that my overlay is actually added, only the View part is missing ...
Below the header file for my overlay class. Comments and variables are in Dutch, if anyone wants a translation I can provide it but I think everything should be clear. I create a overlay with centre coordinate and radius.
The boundingMapRect is calculated from the centre coordinate. Origin is centre minus the radius for both x and y, and the width + height are twice the radius.
#interface PZRMijnOverlay : NSObject <MKOverlay>
{
}
//een property die een bezierpath beschrijft, naar de 2 standaard overlay properties
#property (nonatomic, strong) UIBezierPath *bezierPath;
#property (nonatomic) CLLocationDistance straal;
//class method
+(PZRMijnOverlay *)bezierCirkelMetCenterCoordinate: (CLLocationCoordinate2D)coordinaat enStraal: (CLLocationDistance)eenStraal;
//een eigen designated init
-(id)initWithCenterCoordinate: (CLLocationCoordinate2D)coordinaat enStraal: (CLLocationDistance)eenStraal;
#end
This is de viewForOverlay method implementation:
PZROverlayView *overlayView = [[PZROverlayView alloc] initWithOverlay:(PZRMijnOverlay *)overlay];
overlayView.strokeColor = [UIColor redColor];
overlayView.lineWidth = 10;
//overlayView.strokeColor = [UIColor blackColor];
return overlayView;
Now I guess I should overwrite the createPath method in my PZROverlayView class, but I cannot figure out what code needs to go there. What I tried was to create a UIBezierPath, convert it to CGPath and assign it to the path property of the MKOverlayPathView super class.
Alright, I finally found what I was doing wrong! It is actually way easier than I thought!
Solution:
Add MKCircle overlay
In viewForOverlay: create a bezierPath (CG or UI) and add it to the path property of a standard MKOverlayPathView instance
I was making it myself way too difficult by using custom classes...
I need to change the images/colors (whichever is easier) of buttons in a view different from the one the button is located. Any ideas? This is for iOS and I have been trying for days to get this to work. Thanks!
I don't know if this is the proper way to do this (kinda depends on the context), but you could you us user defaults:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *fooButtonColor = #"red";
[prefs setObject:fooButtonColor forKey:#"fooButtonColor"];
You would put this code in the .m file of the class where you want to "set" the color. In
Then in the other view, get the color from the defaults and check e.g. by doing a string comparison:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:fooButtonColor forKey:#"fooButtonColor"];
NSString *fooButtonColor = [prefs objectForkey:#"fooButtonColor"];
if ([fooButtonColor isEqualtoString #"red"]) {
foobutton.backgroundColor = [UIColor redColor];
}
Probably more efficient would be to use rgba values. Check out this question: Saving UIColor to and loading from NSUserDefaults
Good luck
So I successfully retrieved my BLOB image from the database and set it to NSData *content..
content = [[NSData alloc]
initWithBytes:sqlite3_column_blob(query, 16)
length:sqlite3_column_bytes(query, 16)];
What I am trying to do is to get this content into a NSString, because I would like to then pass this string to javascript and display the image. I am not exactly sure if this is even possible, but i have read on the link below that you can display images in css/html in base64.
http://mark.koli.ch/2009/07/howto-include-binary-image-data-in-cascading-style-sheets-css.html
The issue I am having is converting my NSData to an NSString so I can then put it into my
UIWebView's loadHTMLString....I cannot use a UIImage, must be a UIWebView.
Thanks!
Greg
content = [[NSData alloc] initWithBytes:sqlite3_column_blob(query, 16) length:sqlite3_column_bytes(query, 16)]; NSString *path = [webDirectory stringByAppendingPathComponent:#"image.png"]; [content writeToFile:path atomically:NO]; [content release];
I was able to figure out my solution by writing the file out to a png. Where webDirectory is your directory of choice
Notes as a UITextView in navigation base application .How to save text data after writing in notes .How to identify return from keyboard. need to set any key for return Notes.I need to store device. When user enter the text in notes , after second time able to see previous page also, if its possible write to previous page end of line to start that is appended. plz post some tutorial link , because i am not much about this topic, i need ti understand concept .
Create function that is called on a button click, test if the user has hit enter, or test if the user has removed focus from the UITextView:
-(IBAction)saveText
{
Get the path to the file you want to create:
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:#"savedText.txt"];
Get the text from the UITextView (replace textView with the name of your UITextView):
NSString *savedString = textView.text;
Write the string to the file:
[savedString writeToFile:documentTXTPath atomically:YES];
}