hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

Support for map tiles, expose the "infoWindow" property, expose the Directions API #74

Closed hansemannn closed 7 years ago

hansemannn commented 7 years ago
yozef commented 7 years ago

Tried it with an image in a url structure on my web host, not 100% sure on usage use-case, though I was able to see the image (repeated for a 1/1/1.png)

2017-02-05 at 5 20 48 pm
hansemannn commented 7 years ago

@yozef the url tiles are meant for web-services that provide the tiles dynamically (e.g. the linked open street-map - see the example file). And see this document to learn more about web-tiles.

hansemannn commented 7 years ago

@yozef I also just exposed the Directions API, wanted to try around with NSURLSession :-)

Example response: https://gist.github.com/hansemannn/b979b354ee119b204fca94b5b672bd85

yozef commented 7 years ago

Been trying to figure out a way to display the polyline points, example:

"polyline": {
                "points": "a}dcF~nchVPLXLHQhAsCDKzAyDPe@fAqC`@aAh@sARc@pCoHJUj@yAj@{AL]`@cAd@iAbAiCnC_HjAsCvAqDL_@l@mB`@sA^kAJ[h@aBPi@DSJWDMHSFS@GXaABIBI\\eAHW?ATy@HSPo@"
              }

into : [ [lat, long], [lat, long],...]

and I found this lib to do so: https://github.com/mapbox/polyline which works

hansemannn commented 7 years ago

Exposed the decodePolylinePoints method. Output for the above:

    [{
        latitude = "37.38593";
        longitude = "-122.08384";
    },
        {
        latitude = "37.38584";
        longitude = "-122.08391";
    },
        {
        latitude = "37.38571";
        longitude = "-122.08398";
    },
        {
        latitude = "37.38566";
        longitude = "-122.08389";
    },
        {
        latitude = "37.38529";
        longitude = "-122.08315";
    },
        {
        latitude = "37.38526";
        longitude = "-122.08309";
    },
        {
        latitude = "37.38480000000001";
        longitude = "-122.08216";
    },
        {
        latitude = "37.38471000000001";
        longitude = "-122.08197";
    },
        {
        latitude = "37.38435";
        longitude = "-122.08124";
    },
        {
        latitude = "37.38418";
        longitude = "-122.08091";
    },
        {
        latitude = "37.38397000000001";
        longitude = "-122.08049";
    },
        {
        latitude = "37.38387";
        longitude = "-122.08031";
    },
        {
        latitude = "37.38314";
        longitude = "-122.07879";
    },
        {
        latitude = "37.38308";
        longitude = "-122.07868";
    },
        {
        latitude = "37.38286";
        longitude = "-122.07823";
    },
        {
        latitude = "37.38264";
        longitude = "-122.07777";
    },
        {
        latitude = "37.38257";
        longitude = "-122.07762";
    },
        {
        latitude = "37.3824";
        longitude = "-122.07728";
    },
        {
        latitude = "37.38221";
        longitude = "-122.07691";
    },
        {
        latitude = "37.38187000000001";
        longitude = "-122.07622";
    },
        {
        latitude = "37.38115000000001";
        longitude = "-122.07478";
    },
        {
        latitude = "37.38077000000001";
        longitude = "-122.07404";
    },
        {
        latitude = "37.38033";
        longitude = "-122.07315";
    },
        {
        latitude = "37.38026";
        longitude = "-122.07299";
    },
        {
        latitude = "37.38003";
        longitude = "-122.07244";
    },
        {
        latitude = "37.37986";
        longitude = "-122.07202";
    },
        {
        latitude = "37.3797";
        longitude = "-122.07164";
    },
        {
        latitude = "37.37964";
        longitude = "-122.0715";
    },
        {
        latitude = "37.37943000000001";
        longitude = "-122.07101";
    },
        {
        latitude = "37.37934000000001";
        longitude = "-122.0708";
    },
        {
        latitude = "37.37931";
        longitude = "-122.0707";
    },
        {
        latitude = "37.37925000000001";
        longitude = "-122.07058";
    },
        {
        latitude = "37.37922";
        longitude = "-122.07051";
    },
        {
        latitude = "37.37917";
        longitude = "-122.07041";
    },
        {
        latitude = "37.37913";
        longitude = "-122.07031";
    },
        {
        latitude = "37.37912";
        longitude = "-122.07027";
    },
        {
        latitude = "37.37899";
        longitude = "-122.06994";
    },
        {
        latitude = "37.37897";
        longitude = "-122.06989";
    },
        {
        latitude = "37.37895";
        longitude = "-122.06984";
    },
        {
        latitude = "37.37880000000001";
        longitude = "-122.06949";
    },
        {
        latitude = "37.37875";
        longitude = "-122.06937";
    },
        {
        latitude = "37.37875";
        longitude = "-122.06936";
    },
        {
        latitude = "37.37864";
        longitude = "-122.06907";
    },
        {
        latitude = "37.37859";
        longitude = "-122.06897";
    },
        {
        latitude = "37.3785";
        longitude = "-122.06873";
    }]

Incredible encoding..Saves so much space, wow.

hansemannn commented 7 years ago

@yozef Sorry for making this PR so big, but I just refactored the methods to use an own request factory to be more flexible for more rest api calls :-) Basically, we are now able to call every Google Maps API request simply by using:

    TiGMSHTTPClient *httpClient = [[TiGMSHTTPClient alloc] initWithApiKey:apiKey];
    [httpClient loadWithRequestPath:@"directions/json"
                         andOptions:options
                  completionHandler:^(NSDictionary *json, NSError *error) {
                      // Handle json and error, that's it!
                  }];