-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from hansemannn/feat/heatmaps
feat(android): add heatmap support
- Loading branch information
Showing
7 changed files
with
131 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2021-present by Axway, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
package ti.map; | ||
|
||
import com.google.android.gms.maps.model.LatLng; | ||
import com.google.maps.android.PolyUtil; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import org.appcelerator.titanium.TiC; | ||
import org.appcelerator.titanium.util.TiConvert; | ||
|
||
public class TiMapUtils | ||
{ | ||
// A location can either be a an array of longitude, latitude pairings or | ||
// an array of longitude, latitude objects. | ||
// e.g. [123.33, 34.44], OR {longitude: 123.33, latitude, 34.44} | ||
public static LatLng parseLocation(Object loc) | ||
{ | ||
LatLng location = null; | ||
if (loc instanceof HashMap) { | ||
HashMap<String, String> point = (HashMap<String, String>) loc; | ||
location = new LatLng(TiConvert.toDouble(point.get(TiC.PROPERTY_LATITUDE)), | ||
TiConvert.toDouble(point.get(TiC.PROPERTY_LONGITUDE))); | ||
} else if (loc instanceof Object[]) { | ||
Object[] temp = (Object[]) loc; | ||
location = new LatLng(TiConvert.toDouble(temp[1]), TiConvert.toDouble(temp[0])); | ||
} | ||
return location; | ||
} | ||
|
||
public static ArrayList<LatLng> processPoints(Object points) | ||
{ | ||
ArrayList<LatLng> locationArray = new ArrayList<>(); | ||
|
||
// encoded (result from routing API) | ||
if (points instanceof String) { | ||
List<LatLng> locationList = PolyUtil.decode((String) points); | ||
return new ArrayList<>(locationList); | ||
// multiple points | ||
} else if (points instanceof Object[]) { | ||
Object[] pointsArray = (Object[]) points; | ||
for (int i = 0; i < pointsArray.length; i++) { | ||
Object obj = pointsArray[i]; | ||
LatLng location = TiMapUtils.parseLocation(obj); | ||
locationArray.add(location); | ||
} | ||
return locationArray; | ||
} | ||
return locationArray; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters