Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20092] iOS: Need ability to generate static image of map for the specified coordinates

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-07-17T13:29:54.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsiOS
Labelsqe-6.0.0
ReporterParijat sahai
AssigneeAngel Petkov
Created2015-08-25T06:05:46.000+0000
Updated2016-09-23T13:51:22.000+0000

Description

In the Map module, there should be a method to return a static image of the map for the specified coordinates. Google Maps API has the capability ([Static API](https://developers.google.com/maps/documentation/staticmaps/intro)) and it seems the Apple Mapkit might also have the feature now. This request is fairly urgent and would be easier to implement, I hope. Just want to point out that the "toImage()" method isn't good enough. I'm trying to use it, and although it works fine for a previously loaded map, it doesn't work at all if I only have the coordinates in the code and want to get the image in the background without having to load the map view itself (which takes time).

Comments

  1. Parijat sahai 2016-03-07

    This issue is bigger for iOS, not Android. Please update this ticket to include iOS in the Component list. For iOS, I'm asking you to include the following Apple SDK api: https://developer.apple.com/library/prerelease/ios/documentation/MapKit/Reference/MKMapSnapshotter_class/index.html For Android, currently there exists a workaround to use Google Static Maps API, which might be better. So I'm not as concerned about it. Ideally, it would be better to have ONE module method regardless of the OS, so one doesn't have to create forks in code.
  2. Chee Kiat Ng 2016-03-08

    Thanks! Updated the ticket accordingly to support both platforms.
  3. Parijat sahai 2016-06-13

    Any status update on this feature? It's been just too long.
  4. Parijat sahai 2016-06-14

    You got to be kidding me...it is planned for version 6.0.0? When will it be delivered? It's such a simple change.
  5. Hans Knöchel 2016-06-30

    Hey [~parijatsahai], quality before quantity :-). We are currently working on the feature and will update ti.map as soon as it is finished - as usual. So you will be able to use it in both your current Titanium SDK version, as well as in the upcoming ones. I will ping you with updates asap.
  6. Hans Knöchel 2016-07-17

    [~parijatsahai] Here you go: https://github.com/appcelerator-modules/ti.map/releases/tag/iOS-2.8.0 *Demo*:
       var MapModule = require('ti.map');
       
       var win = Ti.UI.createWindow({
           backgroundColor: 'white'
       });
       
       var Snapshotter = MapModule.createSnapshotter({
           mapType: MapModule.HYBRID_TYPE,
           region: {
               latitude: 37.3382,
               longitude: -121.8863,
               latitudeDelta: 0.4,
               longitudeDelta: 0.4
           },
           size: {
               width: 300,
               height: 200
           }
       });
       
       Snapshotter.takeSnapshot({
           success: function(e) {
               var imageView = Ti.UI.createImageView({
                   image: e.image,
               });
               win.add(imageView);
           },
           error: function(e) {
               Ti.API.error("The snapshot could not be taken: " + e.error);
           }
       });
       
       win.open();
       
  7. Harry Bryant 2016-09-23

    Verified as fixed, tested the above demo code and changed the coordinates to specific locations and the resulting static image correctly reflected the input. Tested On: iPhone 6 Plus 10.0.1 Device & Simulator iPhone 5S 9.3.5 Device Ti.Map (2.8.0) Mac OSX El Capitan 10.11.6 Ti SDK: 6.0.0.v20160922165510 Appc Studio: 4.8.0.201609191928 Appc NPM: 4.2.8-7 App CLI: 6.0.0-51 Xcode 8.0 Node v4.4.7 *Closing ticket.*

JSON Source