Titanium - Make annotation at the user's location - iphone

I am an iPhone developer and a beginner in using Titanium studio. I started to learn Titanium few days back and worked on some samples which uses view, navgroup, images, etc. I'd like to step advance. Now I need to open a mapView in a window and annotate a pin on the user's current location. I have opened a mapView now. I have no idea in getting the user's latitude & longitude and to make annotation at that point. Help me to proceed further with any code or samples. Thanks in advance.

you may get the geoposition by Ti.Geolocation.getCurrentPosition(). And for annotation try this example:
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 ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
});
var mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region: {latitude:33.74511, longitude:-84.38993,
latitudeDelta:0.01, longitudeDelta:0.01},
animate:true,
regionFit:true,
userLocation:true,
annotations:[mountainView]
});
win.add(mapview);
hope it helps :)

Related

OSX/Swift Get Frontmost Running Application

I'm new to swift and osx programming in general, and I need help with one thing that I can't seem to find an answer for. I'm trying to get the frontmost application running on a computer through an app. Right now I'm able to detect when a target application opens, but not when it is in front of all other windows or when it goes into the background.
What I have so far is:
var workspace = NSWorkspace.sharedWorkspace()
var applications = workspace.runningApplications
for app in applications {
let x = "LolClient"
if app.localizedName == x {
println("League is open")
}
}
That will just tell me when a target app opens. I just need to identify what app is in front of all others... basically which one is recieving keystrokes etc. What code would I need to do this? Thank you in advance.
I think you want NSWorkspace.shared.frontmostApplication.
NSWorkspace.shared.frontmostApplication
For the name of the app:
NSWorkspace.shared.frontmostApplication?.localizedName

How to get iPhone Maps app blue dot with light blue field for current location?

I think the title is quite self explanatory. Currently when I add a default annotation for current location:
let currentAnnot = MKPointAnnotation()
currentAnnot.coordinate = loc.coordinate
mainMap.addAnnotation(currentAnnot)
It is giving me a red pin. I want the same blue dot with light blue field which the Apple iPhone Maps app is using by default. Is there a special name for that and how can I add it?
It's because you're adding an annotation (pin) rather than the user location.
Enable it by using the following
mapView.showsUserLocation = true
Also check out a tutorial which may help

Get Application Icon Image From Springboard (Jailbreak)

I'm developing a lockscreen application using theos and part of the functionality requires icon images of certain applications on the phone. How can I go about getting those icon images and displaying them on the lockscreen of the phone?
I've tried everything I could think of so far and have searched through the springboard headers with no luck. I've specifically been trying retrieving the images from SBApplication and SBIconModel from suggestions I found through google, but still I have no luck.
Any help is greatly appreciated. Thanks!
After you %hook a class, inside the method you're using, do the following if for example you're trying to get the icon for the mail app
// Get the SBApplication for the mail app
Class $SBApplicationController = objc_getClass("SBApplicationController");
SBApplication *mailApp = [[$SBApplicationController sharedInstance] applicationWithDisplayIdentifier:#"com.apple.mobilemail"];
// Get the SBApplicationIcon for the mail app
SBApplicationIcon *mailAppIcon = [[objc_getClass("SBApplicationIcon") alloc] initWithApplication:mailApp];
The important thing is to get the right DisplayIdentifier of the app you're interested in.
Hope this help! any problems please shout.
Although, I accept the above as the answer, I ended up using the following code, which displays titles and badges:
SBIcon *sbIcon = [model applicationIconForDisplayIdentifier:identifier];
SBIconView *app = [[%c(SBIconView) alloc] initWithDefaultSize];
[app setIcon:sbIcon];
//if you want the titles to be conditional
[app setLabelHidden:!titlesEnabled];
//if you want the badge view to be conditional
id badgeView;
if (device_version >= 6.0) badgeView = MSHookIvar<id>(app, "_accessoryView");
else badgeView = MSHookIvar<id>(app, "_badgeView");
if (badgeView) [badgeView setHidden:!badgesEnabled];

How to create customized map views

Is it possible to customize the look of maps in iPhone. I am unable to do it using the MapKit.framework. Does anyone know how to do it with the existing framework or in any other way?
After a lot of Research I finally found the link of Google api which allow to create your
custom map view.Basically they provide a link which you need to open in web view and it will
return you an image listed the link below :
http://blog.programmableweb.com/2010/05/20/make-your-google-map-stand-out-with-styles/
Thanks
Rohit Sharma
first add the framework
Then make sure to #import
the map is declared like this in a header file:
MKMapView *mapView;
to show the location of the user:
mapView.showsUserLocation = YES;
You can use the MapKit Framework, to add MKMapView to your app.
Yes, it's possible. You can use the MKOverlayView class to draw your own map in a MKMapView.

How to display a map by mapkit framework in iphone using URL like http://maps.google.com....[it opens map as new App]

When we open : http://maps.google.com & type : category:"motel"+California+USA we get the California region map with the motels in that region. This is done by using MapsApp in iphone. But it closes the current application & opens the map as New App.
Now is it possible to do the same thing with mapkit framework? How to use URL in Mapkit like
http://maps.google.com?q=category....
Add an MKMapView to your application. Take a look at "Specifying the Visible Map Region" to center it on California.
As for showing motels, you would have to handle that manually. You could use a service to find the hotels and then add them to your MKMapView as MKAnnotations.