ios百度地图泡泡怎么自定义弹出泡泡

查看: 149|回复: 0
最后登录15/2/12注册时间12/5/16阅读权限50积分-5精华0帖子金币-15618 枚91币0 枚
钻石: 0 颗
人气: 0 次
金币: -15618 个
发表于 15/12/15 00:38:41
ios百度地图点击annotationView弹出的气泡怎么自定义
帖子永久地址:&<button type="submit" class="pn" onclick="setCopy('ios百度地图点击annotationView弹出的气泡怎么自定义\n/thread--1.html', '帖子地址已经复制到剪贴板您可以用快捷键 Ctrl + V 粘贴到 QQ、MSN 里。')">推荐给好友
GMT+8, 16/4/29 15:21
Powered by百度地图怎么自定义弹出泡泡_百度知道
百度地图怎么自定义弹出泡泡
提问者采纳
&#47.findViewById(R;
mapView.layout./&#47.setCenter(overlayItem.getController();
mapView.findViewById(R;停车场收费类型
TextView tv_reservewarning_pop_parkinglotcurrentstall = (TextView) view.findViewById(R.getContext());
OverlayItem overlayItem = getItem(index);/&#47!= null) {
&#47.findViewById(R;TextView tv_reservewarning_pop_parkinglotname = (TextView)在此处理item点击事件
LayoutInflater inflater = LayoutInflater.tv_reservewarning_pop_parkinglotcurrentstall), null).tv_reservewarning_pop_parkinglotprice), 5).from(mapView,然后在自定义类中的onTap(int index)中设置一个一个弹出窗口来解决这个问题;/业务处理
public boolean onTap(int index) {
&#47.OnClickListener() {
public void onClick(View v) {&#47, overlayItem.OnClickListener() {
public void onClick(View v) {
TextView tv_reservewarning_pop_parkinglotprice = (TextView) view.bt_reservewarning_pop_reserve);&#47.tv_reservewarning_pop_parkinglotaddress);停车场地址
&#47.id.findViewById(R.reserve_warning_
bt_reservewarning_pop_&#47, null).showPopup(view.停车场可预订车位
View view =
if (parkingLot .setOnClickListener(new V停车场名
TextView tv_reservewarning_pop_parkinglotaddress = (TextView) view.getPoint()).inflate(R.id.onTap(index);预定按钮
Button bt_reservewarning_pop_reserve = (Button) view.hidePop().tv_reservewarning_pop_parkinglotname).setOnClickListener(new V弹出自定义界面
popupOverlay = new PopupOverlay(mapView./隐藏弹出窗口
popupO&#47您可以使用自定义类来显示气泡.getPoint();
其他类似问题
为您推荐:
百度地图的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁二次元同好交流新大陆
扫码下载App
汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
public class MainActivity extends MapActivity {&BMapManager mBMapM& MapController mMapC& MKOfflineMap mOffline = //申明变量 离线地图& static View mPopView =&// 点击mark时弹出的气泡View& MyOverItemT overitem =& MapView mMapV&&& @Override&&& public void onCreate(Bundle savedInstanceState) {&&&&&&& super.onCreate(savedInstanceState);&&&&&&& setContentView(R.layout.activity_main);&&&&&&& GeoPoint point =& new GeoPoint((int) ( 22.560034 * 1E6),(int) (113.940657 * 1E6)); &&&&&&& List&GeoPoint& lgp=new ArrayList&GeoPoint&();&&&&&&& lgp.add(point);&&&&&&&& //BMapManager的注册和初始化&&&&&&& mBMapMan = new BMapManager(getApplication());&&&&&&& mBMapMan.init("3B388F055B2942035", null);&&&&&&& mBMapMan.start();&&&&&&& super.initMapActivity(mBMapMan);&&&&&&& //mapview地图控件的设置&&&&&&& mMapView = (MapView) findViewById(R.id.bmapsView);&&&&&&& mMapView.setBuiltInZoomControls(true); //&&&&&&& mMapView.setDrawOverlayWhenZooming(true);//在地图缩放的过程里绘制&&&&&&& mMapView.getController().setCenter(point);//将指定点作为地图的中心显示出来&&&&&&& &&&&&&& &&&&&&& //标记&&&&&&& Drawable marker = getResources().getDrawable(R.drawable.iconmarka); &&&&&&& //为maker定义位置和边界&&&&&&& marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());&& &&&&&&& &&&&&&& //这是在点击了标记之后,弹出的浮动窗口&&mPopView=super.getLayoutInflater().inflate(R.layout.popview, null);&&mMapView.addView( mPopView,&&&&&&&&&&&&&&& new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,&&&&&&&&&&&&&&& &&null, MapView.LayoutParams.TOP_LEFT));&&mPopView.setVisibility(View.GONE);&&&&&&&&&& &&&&&& &&&&&&& overitem=new MyOverItemT(marker,this,lgp);&&&&&&& mMapView.getOverlays().add(overitem);&&& }&&& @Override&&& public boolean onCreateOptionsMenu(Menu menu) {&&&&&&& getMenuInflater().inflate(R.menu.activity_main, menu);&&&&&&&&&& }&&& @Override&&& protected void onDestroy() {&&&&&&& if (mBMapMan != null) {&&&&&&&&&&& mBMapMan.destroy();&&&&&&&&&&& mBMapMan =&&&&&&& }&&&&&&& super.onDestroy();&&& }&&& @Override&&& protected void onPause() {&&&&&&& if (mBMapMan != null) {&&&&&&&&&&& mBMapMan.stop();&&&&&&& }&&&&&&& super.onPause();&&& }&&& @Override&&& protected void onResume() {&&&&&&& if (mBMapMan != null) {&&&&&&&&&&& mBMapMan.start();&&&&&&& }&&&&&&& super.onResume();&&& }&@Override&protected boolean isRouteDisplayed() {&&// TODO Auto-generated method stub&&&}}自定义图层类: class MyOverItemT extends ItemizedOverlay&OverlayItem& {&public List&OverlayItem& mGeoList = new ArrayList&OverlayItem&();&private D//标记&private MainA//上下文&public List&GeoPoint& gpl = new ArrayList&GeoPoint&();&P&//初始化,生成图层的item。&public MyOverItemT(Drawable marker, MainActivity context, List&GeoPoint& gplist) {&&&&& super(boundCenterBottom(marker));&&&&&&&&&& this.marker=&&&&&&&& this.ma=&&&&&&& //根据gplist来制作OverlayItem&&&&&&&& for(int i=0;i&gplist.size();i++){&&&&&&&& &GeoPoint gp=(GeoPoint)gplist.get(i);&&&&&&&& &OverlayItem ot=new OverlayItem(gp,"gp"+i,"gpoint"+i);&&&&&&&& &mGeoList.add(ot);&&&&&&&& }&&&& &populate();//更新&}&//核心的方法& 1 draw:将图层上的item绘制出来&&& 2 onTap:触发每个item的时候响应动作&@Override&public void draw(Canvas canvas, MapView mapView, boolean shadow) {&&& //将List&OverlayItem& mGeoList 全部绘制出来&&// Projection接口用于屏幕像素坐标和经纬度坐标之间的变换&&&&projection = mapView.getProjection(); &&&&//得到OverlayItem,然后转换成point点&&&&//然后根据这个点绘制&&&&for (int index = size() - 1; index &= 0; index--) { &&&&&OverlayItem overLayItem = getItem(index); &&&&&String title = overLayItem.getTitle();&&&&&Point point = projection.toPixels(overLayItem.getPoint(), null); &&&&&Paint paintText = new Paint();&&&&&paintText.setColor(Color.RED);&&&&&paintText.setTextSize(15);&&&&&canvas.drawText(title, point.x-30, point.y, paintText); // 绘制文本&&&&}&&&&super.draw(canvas, mapView, shadow);&&&&boundCenterBottom(marker);&}&@Override&public boolean onTap(GeoPoint arg0, MapView arg1) {&&//浮标消失&&ma.mPopView.setVisibility(View.GONE);&&return super.onTap(arg0, arg1);&}&@Override&protected boolean onTap(int i) {&&//首先 某一个item获得焦点&&//然后将标记图标的view 加入到mapview中&&setFocus(mGeoList.get(i));&&GeoPoint pt = mGeoList.get(i).getPoint();&&Point pn=projection.toPixels(pt, null);&&ma.mMapView.updateViewLayout( ma.mPopView,&&&&&&&&&&&&&&& new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,&&&&&&&&&&&&&&& &&pt, MapView.LayoutParams.BOTTOM_CENTER));&&ma.mPopView.setVisibility(View.VISIBLE);&&&&//得到坐标然后显示出来&&TextView tv1=(TextView)ma.mMapView.findViewById(R.id.tv1);&&tv1.setText("经纬度:"+pt.getLongitudeE6()/1e6+","+pt.getLatitudeE6()/1e6);&&TextView tv2=(TextView)ma.mMapView.findViewById(R.id.tv2);&&tv2.setText("坐标:"+pn.x+","+pn.y);&&&}&@Override&&protected OverlayItem createItem(int arg0) {&&// TODO Auto-generated method stub&&return mGeoList.get(arg0);&}&@Override&public int size() {&&// TODO Auto-generated method stub&&return mGeoList.size();&}}图标的布局样式:&?xml version="1.0" encoding="utf-8"?&&LinearLayout xmlns:android=""&&& android:layout_width="fill_parent"&&& android:layout_height="fill_parent"&&& android:orientation="horizontal"&&& android:paddingBottom="25dip" &&&& &LinearLayout&&&&&&& android:layout_width="wrap_content"&&&&&&& android:layout_height="wrap_content"&&&&&&& android:background="@drawable/pop"&&&&&&& android:orientation="vertical" &&&&&&&& &TextView&&&&&&&&&&& android:id="@+id/tv1"&&&&&&&&&&& android:layout_width="wrap_content"&&&&&&&&&&& android:layout_height="wrap_content"&&&&&&&&&&& android:text="坐标" /&&&&&&&& &TextView&&&&&&&&&&& android:id="@+id/tv2"&&&&&&&&&&& android:layout_width="wrap_content"&&&&&&&&&&& android:layout_height="wrap_content"&&&&&&&&&&& android:text="x,y" /&&&& &/LinearLayout&&/LinearLayout&&
阅读(5635)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Android 百度地图API学习(五)-----气泡显示',
blogAbstract:'一个小例子,在地图中显示一个浮标,显示出我们的标记点,点击这个浮标会出现一个文本显示的气泡
先来看看效果:
public class MainActivity extends MapActivity {&BMapManager mBMapM& MapController mMapC& MKOfflineMap mOffline = //申明变量 离线地图& static View mPopView =&// 点击mark时弹出的气泡View& MyOverItemT overitem =& MapView mMapV',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:5,
publishTime:8,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}二次元同好交流新大陆
扫码下载App
汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(3430)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'百度地图开发:标注点的气泡内容如何修改',
blogAbstract:'Overlay点击的气泡是通过在应用上层添加一个自定义的view实现的,具体参考BMapApiDemoMain例程中的ItemizedOverlayDemo,通过继承ItemizedOverlay&OverlayItem&实现重写标注点的点击响应事件,弹出泡泡的内容是通过mapView.addView添加了一个popview,见layout下的popview.xml,例程中的popview添加的是一个imageview,用户可以任意改变imageview显示的图片,或者放置n个imageview在popview中,也可以修改为EditText等控件。',
blogTag:'百度地图开发,android开发',
blogUrl:'blog/static/4',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:4,
permalink:'blog/static/4',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 ios百度地图泡泡 的文章

 

随机推荐