Reputation: 55
I use a map in my CN1 application. For inject the map in my form, i use this type :
MapContainer mapContainer = new MapContainer();
My app must run only on an IPad tab. I can view my Google map correctly. But i need to style this map. With Javascript i can do this :
var styles = [
{
featureType: "administrative.country",
elementType: "labels",
stylers: [ { color: '#f24547' } ]
}
];
map = new google.maps.Map( document.getElementById('map'), {
center: navigationData.googlePosition,
zoom: 15
});
map.setOptions( { styles: styles } );
How can i do the same in my CN1 java code?
Thanks in advance.
Upvotes: 1
Views: 378
Reputation: 7483
You can't change the styles of native Google Map like that in Codename One but you can set the map type, zoom level, center position and current location.
MapContainer mapContainer = new MapContainer();
mapContainer.setMapType(MapContainer.MAP_TYPE_HYBRID);
mapContainer.setShowMyLocation(true);
LocationManager lm = LocationManager.getLocationManager();
Location loc = lm.getLastKnownLocation();
if (lm.isGPSDetectionSupported()) {
if (lm.isGPSEnabled()) {
Location loc2 = lm.getCurrentLocationSync(20000);
if (loc2 != null) {
loc = loc2;
}
} else {
Dialog.show("", "MyAppName needs access to your current location, please enable GPS in Settings.", "Ok", null);
}
} else {
Location loc2 = lm.getCurrentLocationSync(20000);
if (loc2 != null) {
loc = loc2;
}
}
mapContainer.zoom(new Coord(loc.getLatitude(), loc.getLongitude()), 15);
Upvotes: 2