Gray out entire map except a portion in Google maps iOS - objective-c

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!

Related

Is there any way to draw a line diagram using array of x, y co-ordinates in appcelerator?

If I select one of these co-ordinates, I want to highlight that point on the diagram (by a circle or whatever shape possible). Also I would like to save it later on.
I'm not sure if Appcelerator is flexible enough to do all these things (My search didn't yield much apart from here, this only supports Android), If not I'll have to generate this diagram in my webservice and pull it back on UI once there is an update in the co-ordinate array.
I've used Chartist inside a webview and it worked great. It produces a SVG graph instead of a canvas object which performs better.
If you want to use hyperloop you can use Ti.AndroidCharts

Titanium Appcelerator - Creating Directions Using a Map?

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

Custom icons on google map not drawing correctly

I'm having problems with google maps, drawing icons was working fine few weeks ago in my project. At some time the icons are very frequently drawing in partly and I don't know what is causing it. It is both happening on my development machine and production server and on all machines.
I'm only using two different icons so I know the bitmap images are not corrupt.
Here below are two sample images.
You'll get more help if you post your outputted JSON. Your gmaps JSON must not have quotes around width or height, like so: "picture":"/assets/dayhome.png","width":32,"height":37,"lat":53.5402,"lng":-113.628
Another fix is to include optimized:false which disables the html5 canvas (the squares that are cutting off the markers).
My much more detailed analysis here: Canvas Tiles Cut Off Custom Markers
Set optimized:false in your Marker options.
If optimized is true (the default), then your marker images are incorporated into the tiles. Unfortunately where markers cross tile boundaries, they are not also used on the adjacent tile, so appear to be truncated at the edge of the tile. Using optimized:false forces the icons to be placed on the map as separate DOM objects.

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/

custom colors in bing maps?

I was looking at http://www.msnbc.msn.com/id/26295161/ns/weather/ and noticed that the flash map is provided by bing and have a custom color scheme. I have a similar need to show maps with a black & white colortheme, is it possible using their api or have they made custom tiles ? (doesnt seem feasible to provide tiles for alls maps on all levels :)
If you are not wedded to Bing maps, you could look into Mapbox, which provide maps based on OpenStreetMap in any style that you desire.
This question is still not answered and even if it's kind of old, I think it matters.
In fact, they're not using different tiles or a custom tile scheme. You can see those in the network inspection tool.
Since they're inside a Flash application, they can easily change the color of the image using filter on image (ColorMatrixFilter) and changing dynamically on the client side the rendered colors.
Well now some years later you can: https://msdn.microsoft.com/en-us/library/mt823636.aspx :-)
(I got here by looking for some sample styles and thought I add the link for anybody else finding this question)
Perhaps a custom tile skinner is that you need: http://rbrundritt.wordpress.com/2009/11/27/bing-maps-custom-tile-skinner/
In this example, the author changes the color of roads using ColorMatrix and ColorMap:
The two key methods used to transform the colors
consist of using ColorMatrix or a ColorMap. By
using a color matrix all the colors on the tile
can be changed within a couple lines of code. Using
a ColorMap allows you to change one color at a
time. This is useful if you only want to change a
few colors on the map.