android地图,怎么添加自定义InfoWindow

android地图,怎么添加自定义InfoWindow,第1张

* 初始化AMap对象

*/

private void init() {

if (aMap == null) {

aMap = mapView.getMap()

setUpMap()

}

}

Marker MEIYIDUO

Marker BOLIAN

Marker CUNZHIHUA

private void setUpMap() {

// 自定义系统定位小蓝点

MyLocationStyle myLocationStyle = new MyLocationStyle()

myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.drawable.gps))

myLocationStyle.strokeColor(Color.BLACK)

myLocationStyle.strokeWidth(5)

aMap.setMyLocationStyle(myLocationStyle)

// 设置定位资源

aMap.setLocationSource(this)

// 设置为true表示系统定位按钮显示并响应点击,false表示隐藏,默认是false

aMap.setMyLocationEnabled(true)

CameraUpdate update = CameraUpdateFactory.newLatLngZoom(new

LatLng(23.041725,113.373472), 17)

aMap.moveCamera(update)

在一个Marker上添加一个InfoWindow

设置Markers,并为每一个Marker打开一个InfoWindow

相关代码如下:

google.maps.event.addListener(map, 'click', function(event) {

placeMarker(event.latLng)

})

nction placeMarker(location) {

var marker = new google.maps.Marker({

position: location,

map: map,

})

var infowindow = new google.maps.InfoWindow({

content: 'Latitude: ' + location.lat() +

'<br>Longitude: ' + location.lng()

})

infowindow.open(map,marker)

}

以下是正解:

var html = []

html.push('<input type="button" name="btnOK" onclick="fnOK()" value="确定"> ')

html.push('<a href="#">123</a>')

var info = new BMap.InfoWindow(html.join(""), {offset:new BMap.Size(0,-23),width: 220})

map.openInfoWindow(info, new BMap.Point(121.674223,31.81707))


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11400411.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存