private Boolean updateCenter() { WritableMap properties = getProperties(); if (properties.hasKey(PROP_CENTER)) { try { CameraUpdate cameraUpdate; Double lng = properties.getMap(PROP_CENTER).getDouble("lng"); Double lat = properties.getMap(PROP_CENTER).getDouble("lat"); if (properties.hasKey(PROP_ZOOM_LEVEL)) { int zoomLevel = properties.getInt(PROP_ZOOM_LEVEL); mlastZoom = zoomLevel; Log.i(REACT_CLASS, "Zoom: " + Integer.toString(properties.getInt(PROP_ZOOM_LEVEL))); cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), zoomLevel); } else { Log.i(REACT_CLASS, "Default Zoom."); /* * Changed from cameraUpdate = CameraUpdateFactory.newLatLng(new LatLng(lat, lng)); * as it gave me "zoom" Bugs (defaulted to zoom factor 2) as soon as I put in * "real" LNG and LAT values... */ cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), mlastZoom); } map.animateCamera(cameraUpdate); return true; } catch (Exception e) { // ERROR! e.printStackTrace(); return false; } } else { return false; } }
@ReactProp(name = PROP_CLICK_MARKER) public void setPropClickMarker(MapView view, @Nullable Integer clickMarker) { WritableMap properties = getProperties(); String key = String.valueOf(clickMarker); if (clickMarker == null) { if (properties.hasKey(PROP_CLICK_MARKER)) { if (markerLookup.containsKey(String.valueOf(properties.getInt(PROP_CLICK_MARKER)))) { Marker marker = mapMarkers.get( Integer.parseInt( markerLookup.get(String.valueOf(properties.getInt(PROP_CLICK_MARKER))))); marker.hideInfoWindow(); Log.i(REACT_CLASS, "hideInfoWindow"); } } } else { properties.putInt(PROP_CLICK_MARKER, clickMarker); if (markerLookup.containsKey(key)) { Marker marker = mapMarkers.get(Integer.parseInt(markerLookup.get(key))); marker.showInfoWindow(); Log.i(REACT_CLASS, "showInfoWindow" + String.valueOf(marker)); } } }