├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── AMap_Location_V2.8.0_20160811.jar │ └── Amap_2DMap_V2.9.2_20161026.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── teprinciple │ │ └── yang │ │ └── amapinforwindowdemo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── teprinciple │ │ │ └── yang │ │ │ └── amapinforwindowdemo │ │ │ ├── MainActivity.java │ │ │ ├── adapter │ │ │ └── InfoWinAdapter.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ └── BaseApplication.java │ │ │ ├── entity │ │ │ ├── Constant.java │ │ │ └── Marker.java │ │ │ └── utils │ │ │ ├── CheckPermissionsActivity.java │ │ │ ├── NavigationUtils.java │ │ │ └── PhoneCallUtils.java │ └── res │ │ ├── drawable │ │ ├── inforwindow_bg.png │ │ ├── inforwindow_call.png │ │ ├── inforwindow_navigation.png │ │ ├── marker_normal.png │ │ ├── marker_selected.png │ │ └── mylocation.png │ │ ├── layout │ │ ├── activity_main.xml │ │ └── view_infowindow.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── teprinciple │ └── yang │ └── amapinforwindowdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── preview.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AMapInfoWindowDemo 2 | #### 高德地图自定义Infowindow 3 | 4 | ##### 博客地址:http://www.jianshu.com/p/8365b40d3829 5 | 6 | ##### 预览图 7 | ![](https://github.com/teprinciple/AMapInfoWindowDemo/blob/master/preview.png) 8 | 9 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "teprinciple.yang.amapinforwindowdemo" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile files('libs/Amap_2DMap_V2.9.2_20161026.jar') 27 | compile files('libs/AMap_Location_V2.8.0_20160811.jar') 28 | } 29 | -------------------------------------------------------------------------------- /app/libs/AMap_Location_V2.8.0_20160811.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/libs/AMap_Location_V2.8.0_20160811.jar -------------------------------------------------------------------------------- /app/libs/Amap_2DMap_V2.9.2_20161026.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/libs/Amap_2DMap_V2.9.2_20161026.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\yang5\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/teprinciple/yang/amapinforwindowdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | //地图包、搜索包需要的基础权限 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 31 | 32 | //开发者申请的key 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | 7 | import com.amap.api.location.AMapLocation; 8 | import com.amap.api.location.AMapLocationClient; 9 | import com.amap.api.location.AMapLocationClientOption; 10 | import com.amap.api.location.AMapLocationListener; 11 | import com.amap.api.maps2d.AMap; 12 | import com.amap.api.maps2d.CameraUpdateFactory; 13 | import com.amap.api.maps2d.LocationSource; 14 | import com.amap.api.maps2d.MapView; 15 | import com.amap.api.maps2d.UiSettings; 16 | import com.amap.api.maps2d.model.BitmapDescriptorFactory; 17 | import com.amap.api.maps2d.model.LatLng; 18 | import com.amap.api.maps2d.model.Marker; 19 | import com.amap.api.maps2d.model.MarkerOptions; 20 | import com.amap.api.maps2d.model.MyLocationStyle; 21 | 22 | import teprinciple.yang.amapinforwindowdemo.adapter.InfoWinAdapter; 23 | import teprinciple.yang.amapinforwindowdemo.base.BaseActivity; 24 | import teprinciple.yang.amapinforwindowdemo.entity.Constant; 25 | import teprinciple.yang.amapinforwindowdemo.utils.CheckPermissionsActivity; 26 | 27 | public class MainActivity extends CheckPermissionsActivity implements AMap.OnMapClickListener, AMap.OnMarkerClickListener, AMapLocationListener, LocationSource { 28 | 29 | private MapView mapView; 30 | //声明AMapLocationClient类对象 31 | public AMapLocationClient mLocationClient; 32 | //声明AMapLocationClientOption对象 33 | private AMapLocationClientOption mLocationOption; 34 | private AMap aMap; 35 | private UiSettings uiSettings; 36 | private InfoWinAdapter adapter; 37 | private Marker oldMarker; 38 | private OnLocationChangedListener mListener; 39 | private LatLng myLatLng; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_main); 45 | initView(); 46 | //在执行onCreateView时执行mMapView.onCreate(savedInstanceState),实现地图生命周期管理 47 | mapView.onCreate(savedInstanceState); 48 | initOperation(); 49 | } 50 | 51 | private void initView() { 52 | mapView = (MapView) initV(R.id.mapView); 53 | } 54 | 55 | private void initOperation() { 56 | initMap(); 57 | initLocation(); 58 | } 59 | 60 | /** 61 | * 初始化地图 62 | */ 63 | private void initMap() { 64 | if (aMap == null) { 65 | aMap = mapView.getMap(); 66 | uiSettings = aMap.getUiSettings(); 67 | aMap.setOnMapClickListener(this); 68 | } 69 | uiSettings.setZoomControlsEnabled(false); //隐藏缩放控件 70 | //自定义InfoWindow 71 | aMap.setOnMarkerClickListener(this); 72 | adapter = new InfoWinAdapter(); 73 | aMap.setInfoWindowAdapter(adapter); 74 | 75 | addMarkerToMap(Constant.CHENGDU,"成都","中国四川省成都市"); 76 | } 77 | 78 | 79 | /** 80 | * 初始化定位 81 | */ 82 | private void initLocation(){ 83 | // 自定义系统定位小蓝点--我的位置 84 | MyLocationStyle myLocationStyle = new MyLocationStyle(); 85 | myLocationStyle.myLocationIcon(BitmapDescriptorFactory 86 | .fromResource(R.drawable.mylocation));// 设置小蓝点的图标 87 | myLocationStyle.strokeColor(getResources().getColor(R.color.blue));// 设置圆形的边框颜色 88 | myLocationStyle.radiusFillColor(Color.argb(100, 29, 161, 242));// 设置圆形的填充颜色 89 | myLocationStyle.strokeWidth(1.0f);// 设置圆形的边框粗细 90 | // myLocationStyle.strokeColor(Color.argb(0, 0, 0, 0)); 91 | // myLocationStyle.radiusFillColor(Color.argb(0, 0, 0, 0)); 92 | aMap.setMyLocationStyle(myLocationStyle); 93 | aMap.setLocationSource(this);// 设置定位资源。如果不设置此定位资源则定位按钮不可点击。并且实现activate激活定位,停止定位的回调方法 94 | aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示 95 | aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false 96 | } 97 | 98 | 99 | 100 | //激活定位 101 | //记得注册定位 102 | // 103 | @Override 104 | public void activate(OnLocationChangedListener onLocationChangedListener) { 105 | mListener = onLocationChangedListener; 106 | if (mLocationClient == null) { 107 | mLocationClient = new AMapLocationClient(this); 108 | mLocationOption = new AMapLocationClientOption(); 109 | //设置定位监听 110 | mLocationClient.setLocationListener(this); 111 | //设置为高精度定位模式 112 | mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); 113 | mLocationOption.setOnceLocation(true); 114 | //设置是否返回地址信息(默认返回地址信息) 115 | mLocationOption.setNeedAddress(true); 116 | //设置定位参数 117 | mLocationClient.setLocationOption(mLocationOption); 118 | mLocationClient.startLocation(); 119 | } 120 | } 121 | 122 | //停止定位 123 | @Override 124 | public void deactivate() { 125 | mListener = null; 126 | if (mLocationClient != null) { 127 | mLocationClient.stopLocation(); 128 | mLocationClient.onDestroy(); 129 | } 130 | mLocationClient = null; 131 | } 132 | 133 | 134 | @Override 135 | public void onResume() { 136 | super.onResume(); 137 | mapView.onResume(); //管理地图的生命周期 138 | } 139 | 140 | @Override 141 | public void onPause() { 142 | super.onPause(); 143 | mapView.onPause(); //管理地图的生命周期 144 | } 145 | 146 | @Override 147 | public void onDestroy() { 148 | super.onDestroy(); 149 | mapView.onDestroy(); //管理地图的生命周期 150 | } 151 | 152 | //地图的点击事件 153 | @Override 154 | public void onMapClick(LatLng latLng) { 155 | //点击地图上没marker 的地方,隐藏inforwindow 156 | if (oldMarker != null) { 157 | oldMarker.hideInfoWindow(); 158 | oldMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal)); 159 | } 160 | } 161 | 162 | //maker的点击事件 163 | @Override 164 | public boolean onMarkerClick(Marker marker) { 165 | 166 | if (!marker.getPosition().equals(myLatLng)){ //点击的marker不是自己位置的那个marker 167 | if (oldMarker != null) { 168 | oldMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal)); 169 | } 170 | oldMarker = marker; 171 | marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_selected)); 172 | } 173 | 174 | return false; //返回 “false”,除定义的操作之外,默认操作也将会被执行 175 | } 176 | 177 | //定位成功的监听 178 | @Override 179 | public void onLocationChanged(AMapLocation aMapLocation) { 180 | 181 | if (aMapLocation != null) { 182 | 183 | if(mListener != null){ 184 | // aMap.clear(); 清除之前的marker 185 | mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点-我的位置 186 | } 187 | 188 | if (aMapLocation.getErrorCode() == 0) { 189 | myLatLng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()); 190 | aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myLatLng, 14)); 191 | String city = aMapLocation.getCity(); 192 | String address = aMapLocation.getAddress(); 193 | // addMarkerToMap(latLng,city,address); 194 | } else { 195 | //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。 196 | Log.e("AmapError", "location Error, ErrCode:" + aMapLocation.getErrorCode() + ", errInfo:" 197 | + aMapLocation.getErrorInfo()); 198 | } 199 | } 200 | } 201 | 202 | private void addMarkerToMap(LatLng latLng, String title, String snippet) { 203 | aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f) 204 | .position(latLng) 205 | .title(title) 206 | .snippet(snippet) 207 | .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal)) 208 | ); 209 | } 210 | 211 | } 212 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/adapter/InfoWinAdapter.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.LinearLayout; 8 | import android.widget.TextView; 9 | 10 | import com.amap.api.maps2d.AMap; 11 | import com.amap.api.maps2d.model.LatLng; 12 | import com.amap.api.maps2d.model.Marker; 13 | 14 | import teprinciple.yang.amapinforwindowdemo.base.BaseApplication; 15 | import teprinciple.yang.amapinforwindowdemo.R; 16 | import teprinciple.yang.amapinforwindowdemo.utils.NavigationUtils; 17 | import teprinciple.yang.amapinforwindowdemo.utils.PhoneCallUtils; 18 | 19 | 20 | /** 21 | * Created by Teprinciple on 2016/8/23. 22 | * 地图上自定义的infowindow的适配器 23 | */ 24 | public class InfoWinAdapter implements AMap.InfoWindowAdapter, View.OnClickListener { 25 | private Context mContext = BaseApplication.getIntance().getBaseContext();; 26 | private LatLng latLng; 27 | private LinearLayout call; 28 | private LinearLayout navigation; 29 | private TextView nameTV; 30 | private String agentName; 31 | private TextView addrTV; 32 | private String snippet; 33 | 34 | @Override 35 | public View getInfoWindow(Marker marker) { 36 | initData(marker); 37 | View view = initView(); 38 | return view; 39 | } 40 | @Override 41 | public View getInfoContents(Marker marker) { 42 | return null; 43 | } 44 | 45 | private void initData(Marker marker) { 46 | latLng = marker.getPosition(); 47 | snippet = marker.getSnippet(); 48 | agentName = marker.getTitle(); 49 | } 50 | 51 | @NonNull 52 | private View initView() { 53 | View view = LayoutInflater.from(mContext).inflate(R.layout.view_infowindow, null); 54 | navigation = (LinearLayout) view.findViewById(R.id.navigation_LL); 55 | call = (LinearLayout) view.findViewById(R.id.call_LL); 56 | nameTV = (TextView) view.findViewById(R.id.name); 57 | addrTV = (TextView) view.findViewById(R.id.addr); 58 | 59 | nameTV.setText(agentName); 60 | addrTV.setText(String.format(mContext.getString(R.string.agent_addr),snippet)); 61 | 62 | navigation.setOnClickListener(this); 63 | call.setOnClickListener(this); 64 | return view; 65 | } 66 | 67 | 68 | @Override 69 | public void onClick(View v) { 70 | int id = v.getId(); 71 | switch (id){ 72 | case R.id.navigation_LL: //点击导航 73 | NavigationUtils.Navigation(latLng); 74 | break; 75 | 76 | case R.id.call_LL: //点击打电话 77 | PhoneCallUtils.call("028-"); //TODO 处理电话号码 78 | break; 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.base; 2 | 3 | import android.annotation.TargetApi; 4 | import android.os.Build; 5 | import android.os.Bundle; 6 | import android.support.annotation.IdRes; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.view.Window; 10 | import android.view.WindowManager; 11 | 12 | /** 13 | * Created by Teprinciple on 2016/11/11. 14 | */ 15 | public class BaseActivity extends AppCompatActivity implements View.OnClickListener{ 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | } 20 | 21 | public View initV(@IdRes int id) { 22 | return findViewById(id); 23 | } 24 | 25 | public View initVclick(@IdRes int id) { 26 | View view = initV(id); 27 | view.setOnClickListener(this); 28 | return view; 29 | } 30 | 31 | @Override 32 | public void onClick(View view) { 33 | 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.base; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by Teprinciple on 2016/11/11. 7 | */ 8 | public class BaseApplication extends Application { 9 | 10 | private static BaseApplication mApplication; 11 | 12 | 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | mApplication = this; 17 | 18 | } 19 | 20 | public static BaseApplication getIntance() { 21 | return mApplication; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/entity/Constant.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.entity; 2 | 3 | import com.amap.api.maps2d.model.LatLng; 4 | 5 | /** 6 | * Created by Teprinciple on 2016/11/11. 7 | */ 8 | public class Constant { 9 | 10 | //成都的经纬度 11 | public static final LatLng CHENGDU = new LatLng(30.666482, 104.036407); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/entity/Marker.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.entity; 2 | 3 | /** 4 | * Created by Teprinciple on 2016/11/11. 5 | */ 6 | public class Marker { 7 | 8 | private String name; 9 | private String address; 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | public String getAddress() { 20 | return address; 21 | } 22 | 23 | public void setAddress(String address) { 24 | this.address = address; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/utils/CheckPermissionsActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package teprinciple.yang.amapinforwindowdemo.utils; 5 | 6 | import android.Manifest; 7 | import android.app.Activity; 8 | import android.app.AlertDialog; 9 | import android.content.DialogInterface; 10 | import android.content.Intent; 11 | import android.content.pm.PackageManager; 12 | import android.net.Uri; 13 | import android.provider.Settings; 14 | import android.support.v4.app.ActivityCompat; 15 | import android.support.v4.content.ContextCompat; 16 | import android.support.v7.app.AppCompatActivity; 17 | import android.view.KeyEvent; 18 | 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import teprinciple.yang.amapinforwindowdemo.R; 24 | import teprinciple.yang.amapinforwindowdemo.base.BaseActivity; 25 | 26 | /** 27 | * 继承了Activity,实现Android6.0的运行时权限检测 28 | * 需要进行运行时权限检测的Activity可以继承这个类 29 | * 30 | * @创建时间:2016年5月27日 下午3:01:31 31 | * @项目名称: AMapLocationDemo 32 | * @author hongming.wang 33 | * @文件名称:PermissionsChecker.java 34 | * @类型名称:PermissionsChecker 35 | * @since 2.5.0 36 | */ 37 | public class CheckPermissionsActivity extends BaseActivity 38 | implements 39 | ActivityCompat.OnRequestPermissionsResultCallback { 40 | /** 41 | * 需要进行检测的权限数组 42 | */ 43 | protected String[] needPermissions = { 44 | Manifest.permission.ACCESS_COARSE_LOCATION, 45 | Manifest.permission.ACCESS_FINE_LOCATION, 46 | Manifest.permission.WRITE_EXTERNAL_STORAGE, 47 | Manifest.permission.READ_EXTERNAL_STORAGE, 48 | Manifest.permission.READ_PHONE_STATE 49 | }; 50 | 51 | private static final int PERMISSON_REQUESTCODE = 0; 52 | 53 | /** 54 | * 判断是否需要检测,防止不停的弹框 55 | */ 56 | private boolean isNeedCheck = true; 57 | 58 | @Override 59 | protected void onResume() { 60 | super.onResume(); 61 | if(isNeedCheck){ 62 | checkPermissions(needPermissions); 63 | } 64 | } 65 | 66 | /** 67 | * 68 | * @since 2.5.0 69 | * 70 | */ 71 | private void checkPermissions(String... permissions) { 72 | List needRequestPermissonList = findDeniedPermissions(permissions); 73 | if (null != needRequestPermissonList 74 | && needRequestPermissonList.size() > 0) { 75 | ActivityCompat.requestPermissions(this, 76 | needRequestPermissonList.toArray( 77 | new String[needRequestPermissonList.size()]), 78 | PERMISSON_REQUESTCODE); 79 | } 80 | } 81 | 82 | /** 83 | * 获取权限集中需要申请权限的列表 84 | * 85 | * @param permissions 86 | * @return 87 | * @since 2.5.0 88 | * 89 | */ 90 | private List findDeniedPermissions(String[] permissions) { 91 | List needRequestPermissonList = new ArrayList(); 92 | for (String perm : permissions) { 93 | if (ContextCompat.checkSelfPermission(this, 94 | perm) != PackageManager.PERMISSION_GRANTED) { 95 | needRequestPermissonList.add(perm); 96 | } else { 97 | if (ActivityCompat.shouldShowRequestPermissionRationale( 98 | this, perm)) { 99 | needRequestPermissonList.add(perm); 100 | } 101 | } 102 | } 103 | return needRequestPermissonList; 104 | } 105 | 106 | /** 107 | * 检测是否说有的权限都已经授权 108 | * @param grantResults 109 | * @return 110 | * @since 2.5.0 111 | * 112 | */ 113 | private boolean verifyPermissions(int[] grantResults) { 114 | for (int result : grantResults) { 115 | if (result != PackageManager.PERMISSION_GRANTED) { 116 | return false; 117 | } 118 | } 119 | return true; 120 | } 121 | 122 | @Override 123 | public void onRequestPermissionsResult(int requestCode, 124 | String[] permissions, int[] paramArrayOfInt) { 125 | if (requestCode == PERMISSON_REQUESTCODE) { 126 | if (!verifyPermissions(paramArrayOfInt)) { 127 | showMissingPermissionDialog(); 128 | isNeedCheck = false; 129 | } 130 | } 131 | } 132 | 133 | /** 134 | * 显示提示信息 135 | * 136 | * @since 2.5.0 137 | * 138 | */ 139 | private void showMissingPermissionDialog() { 140 | // AlertDialog.Builder builder = new AlertDialog.Builder(this); 141 | // builder.setTitle(R.string.notifyTitle); 142 | // builder.setMessage(R.string.notifyMsg); 143 | // 144 | // // 拒绝, 退出应用 145 | // builder.setNegativeButton(R.string.cancel, 146 | // new DialogInterface.OnClickListener() { 147 | // @Override 148 | // public void onClick(DialogInterface dialog, int which) { 149 | // finish(); 150 | // } 151 | // }); 152 | // 153 | // builder.setPositiveButton(R.string.setting, 154 | // new DialogInterface.OnClickListener() { 155 | // @Override 156 | // public void onClick(DialogInterface dialog, int which) { 157 | // startAppSettings(); 158 | // } 159 | // }); 160 | // 161 | // builder.setCancelable(false); 162 | // 163 | // builder.show(); 164 | } 165 | 166 | /** 167 | * 启动应用的设置 168 | * 169 | * @since 2.5.0 170 | * 171 | */ 172 | private void startAppSettings() { 173 | Intent intent = new Intent( 174 | Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 175 | intent.setData(Uri.parse("package:" + getPackageName())); 176 | startActivity(intent); 177 | } 178 | 179 | @Override 180 | public boolean onKeyDown(int keyCode, KeyEvent event) { 181 | if(keyCode == KeyEvent.KEYCODE_BACK){ 182 | this.finish(); 183 | return true; 184 | } 185 | return super.onKeyDown(keyCode, event); 186 | } 187 | 188 | } 189 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/utils/NavigationUtils.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.utils; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.widget.Toast; 7 | 8 | import com.amap.api.maps2d.model.LatLng; 9 | 10 | import java.io.File; 11 | 12 | import teprinciple.yang.amapinforwindowdemo.base.BaseApplication; 13 | 14 | 15 | /** 16 | * Created by Teprinciple on 2016/8/22. 17 | * 跳转到高德地图进行导航 18 | */ 19 | public class NavigationUtils { 20 | 21 | private static Context mContext; 22 | 23 | public static void Navigation(LatLng latLng){ 24 | mContext = BaseApplication.getIntance().getBaseContext(); 25 | 26 | 27 | if(isInstallPackage("com.autonavi.minimap")){ 28 | // Toast.makeText(getContext(), "安装有高德地图", Toast.LENGTH_SHORT).show(); 29 | SkipToGD(latLng); 30 | }else { 31 | Toast.makeText(mContext, "请下载安装高德地图", Toast.LENGTH_SHORT).show(); 32 | DownloadMapApp(); 33 | } 34 | } 35 | 36 | /** 37 | * 到应用市场下载高德地图app 38 | */ 39 | private static void DownloadMapApp() { 40 | //显示手机上所有的market商店 41 | Uri uri = Uri.parse("market://details?id=com.autonavi.minimap"); 42 | Intent intent = new Intent(Intent.ACTION_VIEW, uri); 43 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 44 | mContext.startActivity(intent); 45 | } 46 | 47 | /** 48 | * 判断是否安装 高德地图app 49 | * @param packageName 50 | * @return 51 | */ 52 | private static boolean isInstallPackage(String packageName) { 53 | return new File("/data/data/" + packageName).exists(); 54 | } 55 | 56 | /** 57 | * 跳转到高德地图进行导航 58 | */ 59 | private static void SkipToGD(LatLng latLng) { 60 | //跳转导航 61 | //dev 是否偏移(0:lat 和 lon 是已经加密后的,不需要国测加密; 1:需要国测加密) 62 | //style 导航方式(0 速度快; 1 费用少; 2 路程短; 3 不走高速;4 躲避拥堵; 63 | // 5 不走高速且避免收费;6 不走高速且躲避拥堵;7 躲避收费和拥堵;8 不走高速躲避收费和拥堵)) 64 | Uri uri = Uri.parse("androidamap://navi?sourceApplication=CloudPatient&lat="+latLng.latitude+"&lon="+latLng.longitude+"&dev=1&style=2"); 65 | Intent intent = new Intent("android.intent.action.VIEW", uri); 66 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 67 | mContext.startActivity(intent); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/teprinciple/yang/amapinforwindowdemo/utils/PhoneCallUtils.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo.utils; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.text.TextUtils; 7 | 8 | import teprinciple.yang.amapinforwindowdemo.base.BaseApplication; 9 | 10 | 11 | /** 12 | * Created by Teprinciple on 2016/8/22. 13 | * 打电话工具类 14 | */ 15 | public class PhoneCallUtils { 16 | private static Context mContext = BaseApplication.getIntance().getBaseContext();; 17 | public static void call(String phoneNum){ 18 | 19 | if (TextUtils.isEmpty(phoneNum)){ //电话号码为空 20 | return; 21 | } 22 | 23 | Intent intent = new Intent(); 24 | intent.setAction(Intent.ACTION_CALL); 25 | Uri uri = Uri.parse("tel:"+phoneNum); //设置要操作界面的具体内容 拨打电话固定格式: tel: 26 | intent.setData(uri); 27 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 28 | mContext.startActivity(intent); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/inforwindow_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/inforwindow_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/inforwindow_call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/inforwindow_call.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/inforwindow_navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/inforwindow_navigation.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/marker_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/marker_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/marker_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/marker_selected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/mylocation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/drawable/mylocation.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_infowindow.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | 23 | 24 | 35 | 36 | 43 | 44 | 48 | 55 | 61 | 68 | 69 | 70 | 76 | 77 | 84 | 85 | 91 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 108 | 109 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #333333 7 | #666666 8 | #1DA1F2 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AMapDemo 3 | 导航 4 | 电话 5 | 地址:%1$s 6 | 7 | 8 | 提示 9 | 当前应用缺少必要权限。\n\n请点击\"设置\"-\"权限\"-打开所需权限。 10 | 设置 11 | 取消 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/teprinciple/yang/amapinforwindowdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package teprinciple.yang.amapinforwindowdemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teprinciple/AMapInfoWindowDemo/a9973c65ada98a42ea91771ae297da4070c80fb1/preview.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------