Titanium Appcelerator - Creating Directions Using a Map? - titanium

I'm creating a simple Map application in Titanium Appcelerator, right now focusing only on iOS. I have 2 Annotations specified by the latitude and longitude. I want to draw the directions between the 2 points on the Map.
I see the
mapview.addRoute();
method on the MapView object, but it requires you to input all the points in the route to draw it properly?! That doesn't sound right at all - why would it require me to find all the points when the Google Map can do that already.
Is there a way that I'm missing to simply say "here's point A, here's point B, draw the route between the 2 points on the map".

Drawing routes on the map is nothing more than a vector drawing. The same does the mapsapp on your phone.
You will have to interrogate the maps apis for directions,get the directions (points) and use it in your code to draw the route.
If you don't want to do it yourself there is a free module in the marketplace that can help
https://marketplace.appcelerator.com/apps/2580?87150712
If you want to get your hands dirty, this post might help you:
http://developer.appcelerator.com/question/74221/mobile-map-route-from-google-server

Related

Gray out entire map except a portion in Google maps iOS

I am using Google maps in iOS using iOS SDK, letting users mark an area using few markers, creating a polygon.
I want to highlight that area and gray out the rest of the map, something like this:
Is this possible somehow?
You have to draw your own UIImage where you create the gray area, clear area, and polygon borders. After that add it as an overlay tile using GMSGroundOverlay. This will fix it in place for when the user scrolls.
https://developers.google.com/maps/documentation/ios/overlays
This is similar to how radar overlays are drawn for weather apps.
I would approach this problem using several steps.
1) collect your points from the user that will define your polygon.
2) send the collection of points to your server.(ajax post)
3) server side, dynamically create a grey image with a transparent hole in it that is your polygon.
4) store image on server, send back response with info telling browser how to retrieve it(url,id,whatever).
5) using javascript + google maps api, apply an overlay referencing your newly created image.
each step may have its challenges but the problem becomes manageable if you focus on the different steps.
1) and 2) will involve using javascript, capturing 'clicks' and having feedback to the user in the form of a line or something on the map. Once finished, the server call can be initiated by the user or by your programming.
3) I would use python with an image library(skimage, etc.) and a mapping library (gdal). Making an image is not hard but combining it with GIS and getting the right projection, etc. will take some fiddling.
4) shouldn't be a problem once you've got that far.
5) using zimmryan's comment about creating a ground overlay could be helpful for this step.
good luck!

how to highlight countries in ios maps

I am building an app in which I have to highlight some countries dynamically in the world map.
In short I want to customize the whole view of ios maps as shown in the images.
can this be done using MapKit or is there any other method. Thanks in advance
You want to look into the Mapbox iOS SDK which will allow you to do this and more with a MapKit-like API. In particular, you will want to quickly make a custom map with TileMill using the provided Natural Earth data set for world country borders, enable UTFGrid interactivity so that the tapped regions can be identified, and use the RMShape class on an RMAnnotation onto the map view to add/color country polygons as needed. This sounds a little complex but the tools exist, are entirely free and open source, and I can help you with this process.

Drawing maps without base images

I would like to draw a series of maps in an iOS application. Preferably, without using any image files as a base.
For example, I want to draw a map of the United States with states and counties outlined. Does anyone know of a way to do this?
By draw, I mean draw the map in code. Maybe using Apple's Map kit API?
You might want to look in here
http://planet.openstreetmap.org
to get the data. Then you can use the 2d graphics libraries to draw it.

How to find route between two location in iOS5

I know that it's pretty complicated in earlier version, is there any new way around in ios 5.Regarding this i can get locations by using Core locations GEOCoder, But wanted to draw the route between them, also iOS 5 has the ability to show alternate routes for a single destination from the source.
Hope Some One Help Me
Note:I'm using Map kit and core location not UIWebView with Google API.
My Problem : Draw the route between two end location ( origin and destination ).
Development needs: iOS 5 sdk(which has the features to do so),Xcode 4.2.
UI Design : In my case it's very simple design. Two Input text fields and one button then MKMapView.
Frameworks : Map kit framework and Core Location frame work
Development Steps :Get Two Input locations Here i used the method geocodeAddressString: completionHandler: of Geo Coder class(from Core Location Framework) for getting the coordinates for the given location string(Available in iOS5)Used MkPoint Annotation object for creating annotation on the locations in mapThen sent a request to the google API for getting the Direction between two locationAs of the google API Response (Available in both JSON & XML) You would have overview_polyline object , which has the array of location coordinates. But they were encoded, you have to use the correct decoding module to get the latitude and longitude. with the decoded location coordinates you can create the poly lines using MKPolyline instance method. MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:[overlayPoints count]];
[mapView addOverlay:polyLine]; Now the polyline have been drawn over the map still it will not be visible As the final go we have to override the viewForOverlay method for displaying the poly line view.
Hope this may be help full for you guys, if anything you may not understand then let me know.Cheers,Arun
There is no route function in iOS 5 SDK.
So to make a route you need to parse data from route providers, such as Google Maps API or use SDK from CloudMade Maps. Then you use MKPolyline to connect parsed points to show route on MKMapView.
Probably there are existing open-source projects with routes, try to search on github.com.

Adapt a drawn overlay to match roads

In my application I can draw an overlay (PolyLine) on my map (MKMapView). This overlay however, is not bounded to actual roads. Is there a way (some API or others) to adapt the overlay so that it covers/overlays a real road.
The application is run on mobile devices (iPod Touch & iPhone), so to not make my app a very battery consuming one, I would set the Core Location Accuracy not to the highest. As a result, the location will be a bit next to the road where you are. Then I would still like my program to adjust this error...
To get an overlay that matches actual roads, I used Google Maps API Webservices. I already had an array of all points forming a route and I used these points (coordinates) to easily create an overlay that maps on real roads.
I used the first and last point to create a navigation between and set all the other points as 'waypoints', see Directions API
To find the nearest address of a point, I used the Geocoding API
Google Maps API Webservices: http://code.google.com/intl/nl-NL/apis/maps/documentation/webservices/