日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

bminfowindow是什么_三步实现地图自定义InfoWindow

發布時間:2025/3/20 windows 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bminfowindow是什么_三步实现地图自定义InfoWindow 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

現在的app很多都需要接入地圖,不同的app都會定義自己的marker以及InforWindow,本文以高德地圖為例,描述自己自定義InfoWindow之路。

先看看效果圖:

高德地圖的SDK以及接入流程,官方文檔已經寫的很明白了:http://lbs.amap.com/

第一步:自定義InforWindow的布局

android:orientation="horizontal"

android:layout_width="wrap_content"

android:layout_height="127dp"

android:background="#0000"

>

android:layout_width="209dp"

android:layout_height="127dp"

android:orientation="vertical"

android:background="@drawable/inforwindow_bg">

android:id="@+id/agent_name"

android:layout_marginLeft="14dp"

android:layout_marginRight="14dp"

android:layout_marginTop="11dp"

android:layout_width="match_parent"

android:layout_height="20dp"

android:textSize="14sp"

android:textColor="@color/black_text"/>

android:id="@+id/agent_addr"

android:layout_marginLeft="14dp"

android:layout_marginRight="14dp"

android:layout_marginTop="2dp"

android:layout_width="match_parent"

android:layout_height="17dp"

android:singleLine="true"

android:textSize="12sp"

android:textColor="@color/black_text2"/>

android:id="@+id/waitNum"

android:layout_marginLeft="14dp"

android:layout_marginTop="2dp"

android:layout_width="wrap_content"

android:layout_height="17dp"

android:textSize="12sp"

android:textColor="#1DA1F2"/>

android:layout_marginLeft="6dp"

android:layout_marginRight="6dp"

android:layout_width="match_parent"

android:layout_height="1dp"

android:layout_marginTop="9dp"

android:background="#DFDFDF"/>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

android:layout_marginTop="9dp"

android:id="@+id/navigation_LL"

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content"

>

android:layout_marginLeft="27dp"

android:layout_width="17dp"

android:layout_height="18dp"

android:scaleType="centerCrop"

android:src="@drawable/inforwindow_navigation"/>

android:layout_marginLeft="10dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/infowindow_navigation"

android:textSize="14sp"

android:textColor="@color/black_text"/>

android:layout_width="1dp"

android:layout_height="30dp"

android:layout_marginTop="5dp"

android:layout_marginBottom="13dp"

android:background="#DFDFDF"/>

android:layout_marginTop="9dp"

android:id="@+id/call_LL"

android:layout_width="0dp"

android:layout_weight="1"

android:layout_height="wrap_content"

>

android:layout_marginLeft="23dp"

android:layout_width="19dp"

android:layout_height="18dp"

android:scaleType="centerCrop"

android:src="@drawable/inforwindow_call"/>

android:layout_marginLeft="10dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/infowindow_call"

android:textSize="14sp"

android:textColor="@color/black_text"/>

android:layout_width="38dp"

android:layout_height="match_parent" />

第二步、自定義適配器

需要繼承高德地圖的AMap.InfoWindowAdapter

package teprinciple.yang.amapinforwindowdemo.adapter;

import android.content.Context;

import android.support.annotation.NonNull;

import android.view.LayoutInflater;

import android.view.View;

import android.widget.LinearLayout;

import android.widget.TextView;

import com.amap.api.maps2d.AMap;

import com.amap.api.maps2d.model.LatLng;

import com.amap.api.maps2d.model.Marker;

import teprinciple.yang.amapinforwindowdemo.base.BaseApplication;

import teprinciple.yang.amapinforwindowdemo.R;

import teprinciple.yang.amapinforwindowdemo.utils.NavigationUtils;

import teprinciple.yang.amapinforwindowdemo.utils.PhoneCallUtils;

/**

* Created by Teprinciple on 2016/8/23.

* 地圖上自定義的infowindow的適配器

*/

public class InfoWinAdapter implements AMap.InfoWindowAdapter, View.OnClickListener {

private Context mContext = BaseApplication.getIntance().getBaseContext();;

private LatLng latLng;

private LinearLayout call;

private LinearLayout navigation;

private TextView nameTV;

private String agentName;

private TextView addrTV;

private String snippet;

@Override

public View getInfoWindow(Marker marker) {

initData(marker);

View view = initView();

return view;

}

@Override

public View getInfoContents(Marker marker) {

return null;

}

private void initData(Marker marker) {

latLng = marker.getPosition();

snippet = marker.getSnippet();

agentName = marker.getTitle();

}

@NonNull

private View initView() {

View view = LayoutInflater.from(mContext).inflate(R.layout.view_infowindow, null);

navigation = (LinearLayout) view.findViewById(R.id.navigation_LL);

call = (LinearLayout) view.findViewById(R.id.call_LL);

nameTV = (TextView) view.findViewById(R.id.name);

addrTV = (TextView) view.findViewById(R.id.addr);

nameTV.setText(agentName);

addrTV.setText(String.format(mContext.getString(R.string.agent_addr),snippet));

navigation.setOnClickListener(this);

call.setOnClickListener(this);

return view;

}

@Override

public void onClick(View v) {

int id = v.getId();

switch (id){

case R.id.navigation_LL: //點擊導航

NavigationUtils.Navigation(latLng);

break;

case R.id.call_LL: //點擊打電話

PhoneCallUtils.call("028-"); //TODO 處理電話號碼

break;

}

}

}

第三步、調用

package teprinciple.yang.amapinforwindowdemo;

import android.os.Bundle;

import android.util.Log;

import com.amap.api.location.AMapLocation;

import com.amap.api.location.AMapLocationClient;

import com.amap.api.location.AMapLocationClientOption;

import com.amap.api.location.AMapLocationListener;

import com.amap.api.maps2d.AMap;

import com.amap.api.maps2d.CameraUpdateFactory;

import com.amap.api.maps2d.MapView;

import com.amap.api.maps2d.UiSettings;

import com.amap.api.maps2d.model.BitmapDescriptorFactory;

import com.amap.api.maps2d.model.LatLng;

import com.amap.api.maps2d.model.Marker;

import com.amap.api.maps2d.model.MarkerOptions;

import teprinciple.yang.amapinforwindowdemo.adapter.InfoWinAdapter;

import teprinciple.yang.amapinforwindowdemo.base.BaseActivity;

import teprinciple.yang.amapinforwindowdemo.entity.Constant;

import teprinciple.yang.amapinforwindowdemo.utils.CheckPermissionsActivity;

public class MainActivity extends CheckPermissionsActivity implements AMap.OnMapClickListener, AMap.OnMarkerClickListener {

private MapView mapView;

private AMap aMap;

private UiSettings uiSettings;

private InfoWinAdapter adapter;

private Marker oldMarker;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initView();

//在執行onCreateView時執行mMapView.onCreate(savedInstanceState),實現地圖生命周期管理

mapView.onCreate(savedInstanceState);

initOperation();

}

private void initView() {

mapView = (MapView) initV(R.id.mapView);

}

private void initOperation() {

initMap();

}

/**

* 初始化地圖

*/

private void initMap() {

if (aMap == null) {

aMap = mapView.getMap();

uiSettings = aMap.getUiSettings();

aMap.setOnMapClickListener(this);

}

uiSettings.setZoomControlsEnabled(false); //隱藏縮放控件

//自定義InfoWindow

aMap.setOnMarkerClickListener(this);

adapter = new InfoWinAdapter();

aMap.setInfoWindowAdapter(adapter);

addMarkerToMap(Constant.CHENGDU,"成都","中國四川省成都市");

}

@Override

public void onResume() {

super.onResume();

mapView.onResume(); //管理地圖的生命周期

}

@Override

public void onPause() {

super.onPause();

mapView.onPause(); //管理地圖的生命周期

}

@Override

public void onDestroy() {

super.onDestroy();

mapView.onDestroy(); //管理地圖的生命周期

}

//地圖的點擊事件

@Override

public void onMapClick(LatLng latLng) {

//點擊地圖上沒marker 的地方,隱藏inforwindow

if (oldMarker != null) {

oldMarker.hideInfoWindow();

oldMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal));

}

}

//maker的點擊事件

@Override

public boolean onMarkerClick(Marker marker) {

if (oldMarker != null) {

oldMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal));

}

oldMarker = marker;

marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_selected));

return false; //返回 “false”,除定義的操作之外,默認操作也將會被執行

}

private void addMarkerToMap(LatLng latLng, String title, String snippet) {

aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)

.position(latLng)

.title(title)

.snippet(snippet)

.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_normal))

);

}

}

特別注意

顯示infowindow必須設置title或者sinnipet,同時設置aMap.setInfoWindowAdapter(this)

后記

項目地址:https://github.com/teprinciple/AMapInfoWindowDemo

項目中還包括以下功能(均已適配6.0):

1、跳轉到高德地圖進行導航功能

2、定位功能

總結

以上是生活随笔為你收集整理的bminfowindow是什么_三步实现地图自定义InfoWindow的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线日韩三级 | 国产野外作爱视频播放 | 大尺度电影在线 | 麻豆传媒网站 | 天天舔夜夜操 | 欧美日韩人妻精品一区二区三区 | 一级片免费在线 | 亚洲午夜在线观看 | 可以免费看av | 超碰在线观看免费 | 婷婷去俺也去 | 亚洲黄页网站 | 先锋影音制服丝袜 | 日韩一区欧美一区 | 久久丫精品国产亚洲av不卡 | 五月婷婷开心中文字幕 | 国内精品毛片 | av网站在线免费 | 国产色网| 国产美女网 | 亚洲精品久久一区二区三区777 | 免费看黄网站在线观看 | av资源导航 | aaa天堂| 欧美图片一区二区 | 精品国产视频 | 欧美一区二区三区四区五区六区 | 天天躁狠狠躁 | 西西人体做爰大胆gogo | 91啪在线 | 女女同性女同一区二区三区按摩 | 波多一区 | 欧美中文字幕在线 | 国产又色又爽无遮挡免费动态图 | www.中文字幕| 海角社区在线视频播放观看 | 人妻91麻豆一区二区三区 | 国产白丝精品91爽爽久久 | 天天夜夜爽| 免费一级欧美片在线播放 | 亚洲黄色在线网站 | 成年在线观看 | 美日韩成人av | 少妇毛片一区二区三区 | 国产深夜视频 | 亚洲精品国产精品乱码 | 欧美一级日韩 | 日韩黄色大全 | 黄色网址哪里有 | 亚洲在线观看av | 少妇一级1淫片 | 国 产 黄 色 大 片 | 蜜臀视频一区二区 | 欧美性猛交乱大交 | 色永久 | 国产麻豆剧果冻传媒白晶晶 | 吊视频一区二区三区 | av综合站| 超碰人人草人人干 | 免费看黄色a级片 | 日本高清视频一区 | 超碰cc| 亲女禁h啪啪宫交 | 亚洲精品久久久中文字幕 | 美女一级| 一区二区不卡在线 | 一区二区国产在线 | 欧美在线一卡 | 欧美不卡在线观看 | 欧美专区视频 | 国产精品久久久久国产a级 国产一区二区在线播放 | 熟妇人妻系列aⅴ无码专区友真希 | 亚洲AV无码片久久精品 | 欧美精品久久久久 | 国产精品第12页 | 69视频免费观看 | 三级做爰在线观看视频 | 亚洲搞av| 免费无码国产v片在线观看 三级全黄做爰在线观看 | 国产嫩草影院久久久久 | 久久综合免费视频 | 超碰人人人人人人人 | 亚洲熟妇国产熟妇肥婆 | 69xxx国产| 男人天堂aaa | 久久精品免费在线观看 | 四虎最新站名点击进入 | 入禽太深免费视频 | 成人精品福利 | 波多野结衣久久精品 | 亚洲精品国产a | 伊人网av在线 | 欧美成人做爰猛烈床戏 | 97人人模人人爽人人少妇 | 久久精品系列 | 久久久久午夜 | 激情小说激情视频 | 欧美一级片在线视频 | 欧美精品第1页 |