/* * Copyright 2018-2020 NAVER Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.naver.maps.map.demo.java.overlay; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.res.ResourcesCompat; import android.support.v4.graphics.ColorUtils; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import com.naver.maps.geometry.LatLng; import com.naver.maps.map.MapFragment; import com.naver.maps.map.NaverMap; import com.naver.maps.map.OnMapReadyCallback; import com.naver.maps.map.demo.R; import com.naver.maps.map.overlay.CircleOverlay; public class CircleOverlayActivity extends AppCompatActivity implements OnMapReadyCallback { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_fragment); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); } MapFragment mapFragment = (MapFragment)getSupportFragmentManager().findFragmentById(R.id.map_fragment); if (mapFragment == null) { mapFragment = MapFragment.newInstance(); getSupportFragmentManager().beginTransaction().add(R.id.map_fragment, mapFragment).commit(); } mapFragment.getMapAsync(this); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; } return super.onOptionsItemSelected(item); } @Override public void onMapReady(@NonNull NaverMap naverMap) { int color = ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()); CircleOverlay circleOverlay = new CircleOverlay(); circleOverlay.setCenter(new LatLng(37.5666102, 126.9783881)); circleOverlay.setRadius(500); circleOverlay.setColor(ColorUtils.setAlphaComponent(color, 31)); circleOverlay.setOutlineColor(color); circleOverlay.setOutlineWidth(getResources().getDimensionPixelSize(R.dimen.overlay_line_width)); circleOverlay.setMap(naverMap); } }