如何判断点击的是百度地图点击覆盖物还是覆盖物

百度地图API-给自定义覆盖物添加事件方法
百度地图API-给自定义覆盖物添加事件方法
| 时间: 19:26:12 | 阅读数:
[导读] 本文章简单的介绍了一下关于百度地图的应用,这里我介绍一个功能就是在自己定的层上给加个事件方法,有需要的参考一下。给marker、lable、circle等Overlay添加事件很简单,直接addEventListener即可。那么,自定
本文章简单的介绍了一下关于百度地图的应用,这里我介绍一个功能就是在自己定的层上给加个事件方法,有需要的参考一下。
给marker、lable、circle等Overlay添加事件很简单,直接addEventListener即可。那么,自定义覆盖物的事件应该如何添加呢?我们一起来看一看~-----------------------------------------------------------------------------------------一、定义构造函数并继承Overlay
// 定义自定义覆盖物的构造函数 function SquareOverlay(center, length, color){ this._center = this._length = this._color = } // 继承API的BMap.Overlay
SquareOverlay.prototype = new BMap.Overlay();二、初始化自定义覆盖物
// 实现初始化方法
SquareOverlay.prototype.initialize = function(map){
// 保存map对象实例
this._map =
// 创建div元素,作为自定义覆盖物的容器
var div = document.createElement(&div&);
div.style.position = &absolute&;
// 可以根据参数设置元素外观
div.style.width = this._length + &px&;
div.style.height = this._length + &px&;
div.style.background = this._
// 将div添加到覆盖物容器中
map.getPanes().markerPane.appendChild(div);
// 保存div实例
this._div =
// 需要将div元素作为方法的返回值,当调用该覆盖物的show、
// hide方法,或者对覆盖物进行移除时,API都将操作此元素。
三、绘制覆盖物
// 实现绘制方法
SquareOverlay.prototype.draw = function(){
// 根据地理坐标转换为像素坐标,并设置给容器
var position = this._map.pointToOverlayPixel(this._center); this._div.style.left = position.x - this._length / 2 + &px&;
this._div.style.top = position.y - this._length / 2 + &px&;
四、添加覆盖物
//添加自定义覆盖物
var mySquare = new SquareOverlay(map.getCenter(), 100, &red&);
map.addOverlay(mySquare);
五、给自定义覆盖物添加事件1、显示事件
SquareOverlay.prototype.show = function(){
if (this._div){
this._div.style.display = &&;
添加完以上显示覆盖物事件后,只需要下面这句话,就可以显示覆盖物了。
mySquare.show();
2、隐藏覆盖物// 实现隐藏方法
SquareOverlay.prototype.hide = function(){ if (this._div){ this._div.style.display = &none&; } }
添加完以上code,只需使用这句话,即可隐藏覆盖物。mySquare.hide();3、改变覆盖物颜色
SquareOverlay.prototype.yellow = function(){
if (this._div){
this._div.style.background = &yellow&;
上面这句话,是把覆盖物的背景颜色改成黄色,使用以下语句即可生效:mySquare.yellow();&第五部分、给覆盖物添加事件&小结:我们在地图上添加了一个红色覆盖物,然后分别添加&显示、隐藏、改变颜色&的事件。示意图如下:那么,我们需要在html里,先写出map的容器,和3个按钮。
&div style=&width:520height:340border:1px solid gray& id=&container&&&/div&&p&
&input type=&button& value=&移除覆盖物& onclick=&mySquare.hide();& /&
&input type=&button& value=&显示覆盖物& onclick=&mySquare.show();& /&
&input type=&button& value=&变成黄色& onclick=&mySquare.yellow();& /&&/p&
然后,在中,添加这三个函数:
// 实现显示方法
SquareOverlay.prototype.show = function(){
if (this._div){
this._div.style.display = &&;
// 实现隐藏方法
SquareOverlay.prototype.hide = function(){
if (this._div){
this._div.style.display = &none&;
}//改变颜色的方法SquareOverlay.prototype.yellow = function(){
if (this._div){
this._div.style.background = &yellow&;
六、如何给自定义覆盖物添加点击事件(这章重要!很多人问的)比如,我们给自定义覆盖物点击click事件。首先,需要添加一个addEventListener 的事件。如下:
SquareOverlay.prototype.addEventListener = function(event,fun){
this._div['on'+event] =}
再写该函数里面的参数,比如click。这样就跟百度地图API里面的覆盖物事件一样了。
mySquare.addEventListener('click',function(){
alert('click');});
同理,添加完毕addEventListener之后,还可以添加其他鼠标事件,比如mouver。
mySquare.addEventListener('mousemover',function(){
alert('鼠标移上来了');});
七、全部源代码自定义覆盖物
1 &!DOCTYPE html&2 &html&3 &head&4 &meta http-equiv=&Content-Type& content=&text/ charset=utf-8& /&5 &title&自定义覆盖物的点击事件&/title&6 &script type=&text/javascript& src=&http://api./api?v=1.2&&&/script&7 &/head&8 &body&9 &div style=&width:520height:340border:1px solid gray& id=&container&&&/div&10 &p&11 &input type=&button& value=&移除覆盖物& onclick=&mySquare.hide();& /&12 &input type=&button& value=&显示覆盖物& onclick=&mySquare.show();& /&13 &input type=&button& value=&变成黄色& onclick=&mySquare.yellow();& /&14 &/p&15 &/body&16 &/html&17 &script type=&text/javascript&&18 var map = new BMap.Map(&container&); // 创建Map实例19 var point = new BMap.Point(116.404, 39.915); // 创建点坐标20 map.centerAndZoom(point,15); // 初始化地图,设置中心点坐标和地图级别。21 22 //1、定义构造函数并继承Overlay23 // 定义自定义覆盖物的构造函数 24 function SquareOverlay(center, length, color){ 25 this._center = 26 this._length = 27 this._color = 28 } 29 // 继承API的BMap.Overlay 30 SquareOverlay.prototype = new BMap.Overlay(); 31 32 //2、初始化自定义覆盖物33 // 实现初始化方法 34 SquareOverlay.prototype.initialize = function(map){ 35 // 保存map对象实例 36 this._map = 37 // 创建div元素,作为自定义覆盖物的容器 38 var div = document.createElement(&div&); 39 div.style.position = &absolute&; 40 // 可以根据参数设置元素外观 41 div.style.width = this._length + &px&; 42 div.style.height = this._length + &px&; 43 div.style.background = this._ 44 // 将div添加到覆盖物容器中 45 map.getPanes().markerPane.appendChild(div); 46 // 保存div实例 47 this._div = 48 // 需要将div元素作为方法的返回值,当调用该覆盖物的show、 49 // hide方法,或者对覆盖物进行移除时,API都将操作此元素。 50 51 }52 53 //3、绘制覆盖物54 // 实现绘制方法 55 SquareOverlay.prototype.draw = function(){ 56 // 根据地理坐标转换为像素坐标,并设置给容器 57 var position = this._map.pointToOverlayPixel(this._center);58 this._div.style.left = position.x - this._length / 2 + &px&; 59 this._div.style.top = position.y - this._length / 2 + &px&; 60 }61 62 //4、显示和隐藏覆盖物63 // 实现显示方法 64 SquareOverlay.prototype.show = function(){ 65 if (this._div){ 66 this._div.style.display = &&; 67 } 68 } 69 // 实现隐藏方法 70 SquareOverlay.prototype.hide = function(){ 71 if (this._div){ 72 this._div.style.display = &none&; 73 } 74 }75 76 //5、添加其他覆盖物方法77 //比如,改变颜色 78 SquareOverlay.prototype.yellow = function(){ 79 if (this._div){ 80 this._div.style.background = &yellow&; 81 } 82 }83 84 //6、自定义覆盖物添加事件方法85 SquareOverlay.prototype.addEventListener = function(event,fun){86 this._div['on'+event] =87 }88 89 //7、添加自定义覆盖物 90 var mySquare = new SquareOverlay(map.getCenter(), 100, &red&); 91 map.addOverlay(mySquare);92 93 //8、 为自定义覆盖物添加点击事件94 mySquare.addEventListener('click',function(){95 alert('click');96 });97 &/script&
八、感谢大家支持!API常见问题总结贴:/p/&
手机扫描下方二维码,关注php100官方微信。
同步官网每日更新,为您带来随时随地的资讯与技术信息。更有不定期的互动抽奖活动,赢取实用贴心的小礼物。
除非特别声明,PHP100新闻均为原创或投稿报道,转载请注明作者及原文链接原文地址:
友情链接与合作伙伴
粤ICP备号-3如何在鼠标点击处添加一个覆盖物_百度地图api吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:5,237贴子:
如何在鼠标点击处添加一个覆盖物收藏
如题 希望能给个详细的解释
还有 地图定位的时候 设置5s定位一次的话 5s后是自动重新调用 oncreat函数 还是其他的?
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或1223人阅读
百度地图(3)
var BMapLib = window.BMapLib = BMapLib || {};
(function() {
var EARTHRADIUS = ;
var GeoUtils =
BMapLib.GeoUtils = function(){
GeoUtils.isPointInRect = function(point, bounds){
if (!(point instanceof BMap.Point) ||
!(bounds instanceof BMap.Bounds)) {
return false;
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
return (point.lng &= sw.lng && point.lng &= ne.lng && point.lat &= sw.lat && point.lat &= ne.lat);
GeoUtils.isPointInCircle = function(point, circle){
if (!(point instanceof BMap.Point) ||
!(circle instanceof BMap.Circle)) {
return false;
var c = circle.getCenter();
var r = circle.getRadius();
var dis = GeoUtils.getDistance(point, c);
if(dis &= r){
return true;
return false;
GeoUtils.isPointOnPolyline = function(point, polyline){
if(!(point instanceof BMap.Point) ||
!(polyline instanceof BMap.Polyline)){
return false;
var lineBounds = polyline.getBounds();
if(!this.isPointInRect(point, lineBounds)){
return false;
var pts = polyline.getPath();
for(var i = 0; i & pts.length - 1; i++){
var curPt = pts[i];
var nextPt = pts[i + 1];
if (point.lng &= Math.min(curPt.lng, nextPt.lng) && point.lng &= Math.max(curPt.lng, nextPt.lng) &&
point.lat &= Math.min(curPt.lat, nextPt.lat) && point.lat &= Math.max(curPt.lat, nextPt.lat)){
var precision = (curPt.lng - point.lng) * (nextPt.lat - point.lat) -
(nextPt.lng - point.lng) * (curPt.lat - point.lat);
if(precision & 2e-10 && precision & -2e-10){
return true;
return false;
GeoUtils.isPointInPolygon = function(point, polygon){
if(!(point instanceof BMap.Point) ||
!(polygon instanceof BMap.Polygon)){
return false;
var polygonBounds = polygon.getBounds();
if(!this.isPointInRect(point, polygonBounds)){
return false;
var pts = polygon.getPath();
var N = pts.
var boundOrVertex = true;
var intersectCount = 0;
var precision = 2e-10;
var p1, p2;
p1 = pts[0];
for(var i = 1; i &= N; ++i){
if(p.equals(p1)){
return boundOrV
p2 = pts[i % N];
if(p.lat & Math.min(p1.lat, p2.lat) || p.lat & Math.max(p1.lat, p2.lat)){
if(p.lat & Math.min(p1.lat, p2.lat) && p.lat & Math.max(p1.lat, p2.lat)){
if(p.lng &= Math.max(p1.lng, p2.lng)){
if(p1.lat == p2.lat && p.lng &= Math.min(p1.lng, p2.lng)){
return boundOrV
if(p1.lng == p2.lng){
if(p1.lng == p.lng){
return boundOrV
++intersectC
var xinters = (p.lat - p1.lat) * (p2.lng - p1.lng) / (p2.lat - p1.lat) + p1.
if(Math.abs(p.lng - xinters) & precision){
return boundOrV
if(p.lng & xinters){
++intersectC
if(p.lat == p2.lat && p.lng &= p2.lng){
var p3 = pts[(i+1) % N];
if(p.lat &= Math.min(p1.lat, p3.lat) && p.lat &= Math.max(p1.lat, p3.lat)){
++intersectC
intersectCount += 2;
if(intersectCount % 2 == 0){
return false;
return true;
GeoUtils.degreeToRad =
function(degree){
return Math.PI * degree/180;
GeoUtils.radToDegree = function(rad){
return (180 * rad) / Math.PI;
function _getRange(v, a, b){
if(a != null){
v = Math.max(v, a);
if(b != null){
v = Math.min(v, b);
function _getLoop(v, a, b){
while( v & b){
v -= b - a
while(v & a){
v += b - a
GeoUtils.getDistance = function(point1, point2){
if(!(point1 instanceof BMap.Point) ||
!(point2 instanceof BMap.Point)){
point1.lng = _getLoop(point1.lng, -180, 180);
point1.lat = _getRange(point1.lat, -74, 74);
point2.lng = _getLoop(point2.lng, -180, 180);
point2.lat = _getRange(point2.lat, -74, 74);
var x1, x2, y1, y2;
x1 = GeoUtils.degreeToRad(point1.lng);
y1 = GeoUtils.degreeToRad(point1.lat);
x2 = GeoUtils.degreeToRad(point2.lng);
y2 = GeoUtils.degreeToRad(point2.lat);
return EARTHRADIUS * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1) * Math.cos(y2) * Math.cos(x2 - x1)));
GeoUtils.getPolylineDistance = function(polyline){
if(polyline instanceof BMap.Polyline ||
polyline instanceof Array){
if(polyline instanceof BMap.Polyline){
pts = polyline.getPath();
if(pts.length & 2){
var totalDis = 0;
for(var i =0; i & pts.length - 1; i++){
var curPt = pts[i];
var nextPt = pts[i + 1]
var dis = GeoUtils.getDistance(curPt, nextPt);
totalDis +=
return totalD
GeoUtils.getPolygonArea = function(polygon){
if(!(polygon instanceof BMap.Polygon) &&
!(polygon instanceof Array)){
if(polygon instanceof BMap.Polygon){
pts = polygon.getPath();
if(pts.length & 3){
var totalArea = 0;
var LowX = 0.0;
var LowY = 0.0;
var MiddleX = 0.0;
var MiddleY = 0.0;
var HighX = 0.0;
var HighY = 0.0;
var AM = 0.0;
var BM = 0.0;
var CM = 0.0;
var AL = 0.0;
var BL = 0.0;
var CL = 0.0;
var AH = 0.0;
var BH = 0.0;
var CH = 0.0;
var CoefficientL = 0.0;
var CoefficientH = 0.0;
var ALtangent = 0.0;
var BLtangent = 0.0;
var CLtangent = 0.0;
var AHtangent = 0.0;
var BHtangent = 0.0;
var CHtangent = 0.0;
var ANormalLine = 0.0;
var BNormalLine = 0.0;
var CNormalLine = 0.0;
var OrientationValue = 0.0;
var AngleCos = 0.0;
var Sum1 = 0.0;
var Sum2 = 0.0;
var Count2 = 0;
var Count1 = 0;
var Sum = 0.0;
var Radius = EARTHRADIUS;
var Count = pts.
for (var i = 0; i & C i++) {
if (i == 0) {
LowX = pts[Count - 1].lng * Math.PI / 180;
LowY = pts[Count - 1].lat * Math.PI / 180;
MiddleX = pts[0].lng * Math.PI / 180;
MiddleY = pts[0].lat * Math.PI / 180;
HighX = pts[1].lng * Math.PI / 180;
HighY = pts[1].lat * Math.PI / 180;
else if (i == Count - 1) {
LowX = pts[Count - 2].lng * Math.PI / 180;
LowY = pts[Count - 2].lat * Math.PI / 180;
MiddleX = pts[Count - 1].lng * Math.PI / 180;
MiddleY = pts[Count - 1].lat * Math.PI / 180;
HighX = pts[0].lng * Math.PI / 180;
HighY = pts[0].lat * Math.PI / 180;
LowX = pts[i - 1].lng * Math.PI / 180;
LowY = pts[i - 1].lat * Math.PI / 180;
MiddleX = pts[i].lng * Math.PI / 180;
MiddleY = pts[i].lat * Math.PI / 180;
HighX = pts[i + 1].lng * Math.PI / 180;
HighY = pts[i + 1].lat * Math.PI / 180;
AM = Math.cos(MiddleY) * Math.cos(MiddleX);
BM = Math.cos(MiddleY) * Math.sin(MiddleX);
CM = Math.sin(MiddleY);
AL = Math.cos(LowY) * Math.cos(LowX);
BL = Math.cos(LowY) * Math.sin(LowX);
CL = Math.sin(LowY);
AH = Math.cos(HighY) * Math.cos(HighX);
BH = Math.cos(HighY) * Math.sin(HighX);
CH = Math.sin(HighY);
CoefficientL = (AM * AM + BM * BM + CM * CM) / (AM * AL + BM * BL + CM * CL);
CoefficientH = (AM * AM + BM * BM + CM * CM) / (AM * AH + BM * BH + CM * CH);
ALtangent = CoefficientL * AL - AM;
BLtangent = CoefficientL * BL - BM;
CLtangent = CoefficientL * CL - CM;
AHtangent = CoefficientH * AH - AM;
BHtangent = CoefficientH * BH - BM;
CHtangent = CoefficientH * CH - CM;
AngleCos = (AHtangent * ALtangent + BHtangent * BLtangent + CHtangent * CLtangent) / (Math.sqrt(AHtangent * AHtangent + BHtangent * BHtangent + CHtangent * CHtangent) * Math.sqrt(ALtangent * ALtangent + BLtangent * BLtangent + CLtangent * CLtangent));
AngleCos = Math.acos(AngleCos);
ANormalLine = BHtangent * CLtangent - CHtangent * BL
BNormalLine = 0 - (AHtangent * CLtangent - CHtangent * ALtangent);
CNormalLine = AHtangent * BLtangent - BHtangent * AL
if (AM != 0)
OrientationValue = ANormalLine / AM;
else if (BM != 0)
OrientationValue = BNormalLine / BM;
OrientationValue = CNormalLine / CM;
if (OrientationValue & 0) {
Sum1 += AngleC
Sum2 += AngleC
var tempSum1, tempSum2;
tempSum1 = Sum1 + (2 * Math.PI * Count2 - Sum2);
tempSum2 = (2 * Math.PI * Count1 - Sum1) + Sum2;
if (Sum1 & Sum2) {
if ((tempSum1 - (Count - 2) * Math.PI) & 1)
Sum = tempSum1;
Sum = tempSum2;
if ((tempSum2 - (Count - 2) * Math.PI) & 1)
Sum = tempSum2;
Sum = tempSum1;
totalArea = (Sum - (Count - 2) * Math.PI) * Radius * R
return totalA
使用方法:
var point = new BMap.Point(x,y)
var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
if(BMapLib.GeoUtils.isPointInCircle(point,circle)){
alert("该point在circle内");
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
需要交换友链的请留言
访问:1290108次
积分:23067
积分:23067
排名:第199名
原创:537篇
转载:23篇
译文:26篇
评论:1436条如何在百度地图里面添加覆盖物,并且对每个覆盖物添加点击之后弹出信息框的功能_百度知道
如何在百度地图里面添加覆盖物,并且对每个覆盖物添加点击之后弹出信息框的功能
+ dizhi[i].toString() + &quot.val();p style='p&
for (var i = 0,点击任意覆盖物.val();).split(' 将标注添加到地图中
}我这样写的话;&font-size.val();'#HiddenField7&创建站点信息窗口
var infoWindow2 = new BMap.length-1;p style='font-size.toString() + &;, y[i]; 站点地址;#HiddenField6&//站点名称;
&#47.val();-'-&#39:14px.Size(25;); + name[i];
var marker2 = new BM 负责人;););).val();&p&#HiddenField3&quot:14-');;
var html = &click&#HiddenField1&-&#39.split('zixingche_&quot, {/);font-
/&&).split(&#39, new BM-'//&gtvar x = $(&quot:&#HiddenField5&quot.toString().Point(x[i];&& 创建标注
map.toString() + &quot,最后显示的信息;-&#39:&
var dizhi = $(&/
var y = $(&quot.Window(html);'
var fuzeren = $(&quot, function () { }).Marker('电话.split('):&#HiddenField2&quot.split(&#39.addOverlay(marker2).toString() + &
var myIcon = new BMap,都是数组中.val(); i++) {
var pt = new BMap.toString() + &-&#39.toString());当前车辆数.split(');;&lt, 25)).addEventListener(&);p&gt,怎么才能 信息和覆盖物对应呢;
var dangqiancheliangshu = $(& + dianhua[i].split('
var name = $(&;img/ i &p style='
/):&quot:14px:&quot,最后一个的值;);); + dangqiancheliangshu[i];
var dianhua = $(&#HiddenField4&quot: myIcon });&lt.val().openInfoWindow(infoWindow2); + fuzeren[i].Icon(&quot
///zhidao/pic/item/e1fe3b1fd47f8fb1cb./zhidao/wh%3D600%2C800/sign=8e7cb37bb4fd29b28bb13/e1fe3b1fd47f8fb1cb://h.hiphotos.hiphotos,所有点.baidu。然后现在的结果就是,点击都是最后一条信息结果就是这样://h
提问者采纳
使用闭包添加事件,不懂自己查,或者问
提问者评价
虽然就只有这么一句话,自己去找找,研究了下。。出来了。。谢了~~
其他类似问题
为您推荐:
百度地图的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁后使用快捷导航没有帐号?
暂时没有人问过相似的问题,你可以做第一个提问题的人
查看: 3396|回复: 11
SDK3.1.1地图覆盖物如何判断用户点击了哪一个覆盖物
List&LatLng& list = new ArrayList&LatLng&();
list.add(new LatLng(studioLat, studioLon));
& & & & & & & & list.add(new LatLng(31.0.466979));
& & & & & & & & list.add(new LatLng(31.0.607834));
& & & & & & & & list.add(new LatLng(31.0.637154));
& & & & & & & & list.add(new LatLng(31.0.945884));
& & & & & & & & // add marker overlay
& & & & & & & & for (int i = 0; i & list.size(); i++) {
& & & & & & & & & & & & OverlayOptions overlay = new MarkerOptions().position(list.get(i))
& & & & & & & & & & & & & & & & & & & & .icon(bd).zIndex(9).draggable(true);
& & & & & & & & & & & & mMarker = (Marker) (mBaiduMap.addOverlay(overlay));
& & & & & & & & }复制代码
比如说上面一段代码,在setOnMarkerClickListener这个方法里也并没有之前版本中的ontap(int index)这样的索引值提供,所以敢问版主,怎样才能判断用户点击了哪一个标注覆盖物呢
360手机助手截图_01.png (322.65 KB, 下载次数: 0)
19:23 上传
如图所示,三个覆盖物,点击后弹出的infowindow都是一样的,看了demo里的判断,不太能看懂,感觉无法重用到我上面那一段代码中
现在里面不是 marker 么& & 那个回调里面
mBaiduMap.setOnMarkerClickListener(new OnMarkerClickListener() {
& & & & & & & & & & & &
& & & & & & & & & & & & @Override
& & & & & & & & & & & & public boolean onMarkerClick(Marker arg0) {
& & & & & & & & & & & & & & & & // TODO Auto-generated method stub
& & & & & & & & & & & & & & & &
& & & & & & & & & & & & }
& & & & & & & & });复制代码
& &是marker,但我怎么知道用户点的是哪个marker呢
你的这个点击的是地图,他说的应该是图层上的那个回调@Override
public boolean onMarkerClick(Marker mark) {
infowindow_park = new InfoWindow(inforView_park,
mark.getPosition(), -16);
text_name.setText(mark.getTitle());
index_park = mark.getZIndex();
mBaiduMap.showInfoWindow(infowindow_park);
& &我是这样写的,点击气泡,可以显示信息
柯南_新一_我
& &那你这个回调是在哪用的,就是这个方法是怎么点出来的?
& &如果有多个覆盖物图层,又该如何对应
private class MyOm extends OverlayManager {
private BaiduM
public void setResult() {
public MyOm(BaiduMap bdmap) {
super(bdmap);
this.bdmap =
public boolean onMarkerClick(Marker mark) {
infowindow_park = new InfoWindow(inforView_park,
mark.getPosition(), -16);
text_name.setText(mark.getTitle());
index_park = mark.getZIndex();
mBaiduMap.showInfoWindow(infowindow_park);
public List&OverlayOptions& getOverlayOptions() {
List&OverlayOptions& ops = new ArrayList&OverlayOptions&();
BitmapDescriptor bitmap = BitmapDescriptorFactory
.fromResource(R.drawable.p
我是这样添加的
调用MyOm overlay = new MyOm(mBaiduMap);
本帖最后由 diyangxia 于
10:18 编辑
柯南_新一_我
不会用啊!你看效果图是这样:
demo.gif (142.89 KB, 下载次数: 0)
10:17 上传
这个overlayManager能得到对应位置的索引吗
bitmap = BitmapDescriptorFactory
.fromResource(R.drawable.park_gree);
& &for (int i = 0; i & ParkList.size(); i++) {
LatLng la = new LatLng(ParkList.get(i)
.getlatitude(), ParkList.get(i)
.getlongitude());
OverlayOptions op = new MarkerOptions()
.position(la)
.icon(bitmap)
.title(ParkList.get(i)
.getParkName());
ops.add(op);
bdmap.addOverlay(op).setZIndex(i);
index_park = mark.getZIndex();这个就是获取索引了
本帖最后由 diyangxia 于
11:26 编辑
柯南_新一_我
marker.getZIndex()复制代码
就这么一句代码,看官方的api
getZIndex public int getZIndex()
获取覆盖物 zIndex
返回:覆盖物 zIndex
我也是醉了;
本帖最后由 diyangxia 于
11:43 编辑
柯南_新一_我
& &话说你有没有用过最新版的poi检索功能接口,虽然有附近周边检索的接口,但是检索出来的结果详情总是说找不到
现在里面不是 marker 么& & 那个回调里面
问一下,怎么样在MarkerOptions下建立的mark,让它在百度地图显示图标的同时,在其图标下面显示自己想要加的话?
Powered by

我要回帖

更多关于 高德地图自定义覆盖物 的文章

 

随机推荐