[小程序开发]在地图上标记头像并显示名字

2022年11月25日 12:11 by wst

小程序

小程序开发过程中,我们怎么标记每个人的位置,并显示头像呢?

下面对这个功能进行演示,代码如下:

基础版本库:2.24.7

pages/onemap/onemap.wxml

<map 
  id="myMap" 
  style="width: 710rpx; height: 300px;" 
  latitude="{{latitude}}" 
  longitude="{{longitude}}" 
  markers="{{markers}}" 
  show-location>
</map>

pages/onemap/onemap.wxss

map{
  margin: 20rpx;
}

pages/onemap/onemap.js

Page({
  data: {
    latitude: 39.944126,
    longitude: 116.453766,
    markers: [],
  },
  onReady: function (e) {
    //创建 map 上下文 MapContext 对象。
    this.mapCtx = wx.createMapContext('myMap')
    // 设置边界
    const pos = {
      southwest: {
        latitude: 39.944092,
        longitude: 116.453605,
      },
      northeast: {
        latitude: 39.944293,
        longitude: 116.454098,
      }
    }
    // 设置地图边界
    this.mapCtx.setBoundary(pos)
    // 渲染标注点
    const marks = [
      {id: 1, title: '李易峰', latitude:39.944262, longitude: 116.453782, iconPath: "http://www.wanhuqianjia.com/static/wximg/%E6%9D%8E%E6%98%93%E5%B3%B0-modified.png", width: 50, height: 50,  label: {content: '李易峰', anchorX: 10, anchorY: -25, color: 'red'}},
      {id: 2, title: '陈冠希', latitude: 39.944207, longitude: 116.453823,  iconPath: "http://www.wanhuqianjia.com/static/wximg/%E9%99%88%E5%86%A0%E5%B8%8C-modified.png", width: 50, height: 50, label: {content: '陈冠希', anchorX: 10, anchorY: -25, color: 'red'}},
      {id: 3, title: '张一山', latitude: 39.944259, longitude: 116.454053,  iconPath: "http://www.wanhuqianjia.com/static/wximg/%E5%BC%A0%E4%B8%80%E5%B1%B1-modified.png", width: 50, height: 50, label: {content: '张一山', anchorX: 10, anchorY: -25, color: 'red'}},
      {id: 4, title: '杨紫', latitude: 39.944145, longitude: 116.453937,  iconPath: "http://www.wanhuqianjia.com/static/wximg/%E6%9D%A8%E7%B4%AB-modified.png", width: 50, height: 50, label: {content: '杨紫', anchorX: 10, anchorY: -25, color: 'red'}},
      {id: 5, title: '赵丽颖', latitude: 39.94415, longitude: 116.453651,  iconPath: "http://www.wanhuqianjia.com/static/wximg/%E8%B5%B5%E4%B8%BD%E9%A2%96-modified.png", width: 50, height: 50, label: {content: '赵丽颖', anchorX: 10, anchorY: -25, color: 'red'}},
    ]
    this.setData({markers: marks})
  },
  //获取当前地图的缩放级别
  scaleClick: function(){
    this.mapCtx.getScale({
      success: function (res) {
        console.log(res.scale)
      }
    })
  },
  //获取当前地图的视野范围
  getRegionClick: function () {
    this.mapCtx.getRegion({
      success: function (res) {
        console.log(res.southwest)
        console.log(res.northeast)
      }
    })
  }
})

效果如下:

 源代码:下载


Comments(127) Add Your Comment

Nfkogz
order lipitor 10mg <a href="https://lipiws.top/">order lipitor 40mg generic</a> buy generic atorvastatin 20mg
Iytatt
order cipro 1000mg pills - <a href="https://cipropro.top/bactrimos/">brand septra</a> buy augmentin generic
Kjmgeu
generic ciprofloxacin 1000mg - <a href="https://metroagyl.top/azithromycin/">augmentin online order</a> purchase augmentin for sale
Xsqdln
ciprofloxacin pills - <a href="https://septrim.top/chloromycetin/">buy chloramphenicol</a> cheap erythromycin 250mg
Wtgzrx
flagyl 400mg without prescription - <a href="https://metroagyl.top/clindamycin/">order cleocin 300mg online cheap</a> zithromax 250mg generic
Ibjizt
covid and ivermectin - <a href="https://keflexin.top/sumycin/">cheap sumycin online</a> sumycin 500mg usa
Fvkxnm
buy valtrex generic - <a href="https://gnantiviralp.com/nemasole/">order nemasole generic</a> zovirax 400mg for sale
Hjbaoa
buy acillin <a href="https://ampiacil.top/">buy ampicillin generic</a> amoxil cheap
Gxpowy
how to get flagyl without a prescription - <a href="https://metroagyl.top/">purchase metronidazole for sale</a> generic azithromycin
Nchenf
buy furosemide pills for sale - <a href="https://antipathogenc.com/capoten/">capoten 25 mg ca</a> order captopril 25mg generic
Sijpdr
buy glycomet 500mg generic - <a href="https://gnantiacidity.com/">glucophage 500mg pills</a> lincomycin us
Imrguh
order zidovudine 300mg pills - <a href="https://canadiangnp.com/avapro/">how to get avapro without a prescription</a> order allopurinol 100mg generic
Jbpppq
cost clozaril - <a href="https://genonlinep.com/accupril/">accupril online order</a> buy pepcid 40mg sale
Khsybv
order quetiapine sale - <a href="https://gnkantdepres.com/eskalith/">eskalith canada</a> purchase eskalith online
Bxmiby
order anafranil for sale - <a href="https://antdeponline.com/sinequan/">doxepin order</a> brand sinequan 25mg
Qdajua
purchase atarax without prescription - <a href="https://antdepls.com/lexapro/">order lexapro pills</a> order endep 25mg online
Gxziwp
order generic augmentin 1000mg - <a href="https://atbioinfo.com/septra/">bactrim 480mg tablet</a> buy generic cipro online
Pvmovp
cheap amoxicillin without prescription - <a href="https://atbioxotc.com/ceftin/">buy axetil for sale</a> ciprofloxacin 500mg brand
Mywfyj
order azithromycin without prescription - <a href="https://gncatbp.com/ctinidazole/">generic tinidazole 500mg</a> buy generic ciplox 500mg
Kfhcig
oral cleocin - <a href="https://cadbiot.com/cefpodoxime/">generic vantin 100mg</a> buy chloramphenicol pills for sale
Wvxdli
ivermectin 3 mg for sale - <a href="https://antibpl.com/szdoryx/">order doryx pills</a> order cefaclor 500mg sale
Ozqdic
purchase albuterol inhalator generic - <a href="https://antxallergic.com/advairdiskus/">buy advair diskus without prescription</a> order theophylline 400 mg for sale
Claqmw
buy methylprednisolone generic - <a href="https://ntallegpl.com/getcetirizine/">order cetirizine 5mg online cheap</a> astelin 10 ml drug
Taydxr
desloratadine medication - <a href="https://rxtallerg.com/ventolinpill/">generic albuterol</a> buy generic albuterol online
Cqwjee
micronase 2.5mg without prescription - <a href="https://prodeprpl.com/glipizide10/">glucotrol 5mg pills</a> forxiga buy online
Iyvfhj
order metformin 500mg sale - <a href="https://arxdepress.com/sitagliptin50/">sitagliptin 100mg brand</a> order precose 25mg for sale
Zqyseo
buy prandin paypal - <a href="https://depressinfo.com/">buy prandin 1mg sale</a> empagliflozin 25mg uk
Gcfqco
order lamisil without prescription - <a href="https://treatfungusx.com/fulvicin250mg/">order griseofulvin 250 mg generic</a> buy grifulvin v online cheap
Dcoucn
buy rybelsus generic - <a href="https://infodeppl.com/glucovance5/">purchase glucovance for sale</a> buy cheap generic DDAVP
Zrlmgi
nizoral 200mg brand - <a href="https://antifungusrp.com/">nizoral pills</a> buy sporanox 100 mg pills
Gxbnms
buy famciclovir 500mg pills - <a href="https://amvinherpes.com/gnvalaciclovir/">valaciclovir pills</a> valcivir 500mg tablet
Sntlny
lanoxin 250mg sale - <a href="https://blpressureok.com/">digoxin 250 mg pill</a> buy furosemide 100mg pill
Tkeckl
lopressor cheap - <a href="https://bloodpresspl.com/olmesartan/">order benicar for sale</a> nifedipine sale
Fezjxx
microzide 25mg canada - <a href="https://norvapril.com/lisinopril/">how to buy lisinopril</a> bisoprolol 5mg sale
Sbvsnp
nitroglycerin ca - <a href="https://nitroproxl.com/valsartan/">valsartan 80mg tablet</a> diovan 80mg without prescription
Nrmrvk
rosuvastatin puff - <a href="https://antcholesterol.com/pravastatin/">pravastatin buy corner</a> caduet pills fully
Ogiwkb
zocor city - <a href="https://canescholest.com/">simvastatin central</a> lipitor absorb
Jmkjrc
viagra professional online insist - <a href="https://edsildps.com/">viagra professional trot</a> levitra oral jelly online horn
Mwnumv
dapoxetine opinion - <a href="https://promedprili.com/aurogra/">aurogra least</a> cialis with dapoxetine quarrel
Bucwyg
cenforce way - <a href="https://xcenforcem.com/tadaciptadalafil/">tadacip pills fruit</a> brand viagra amazement
Ecrfgx
brand cialis source - <a href="https://probrandtad.com/viagrasofttabs/">viagra soft tabs message</a> penisole sweep
Wbwmpb
cialis soft tabs pills whip - <a href="https://supervalip.com/valifonline/">valif online quiver</a> viagra oral jelly ear
Wsmmmi
brand cialis sky - <a href="https://probrandtad.com/brandlevitra/">brand levitra kill</a> penisole success
Icqice
cialis soft tabs online log - <a href="https://supervalip.com/cialissuperactive/">cialis super active online desert</a>1 viagra oral jelly threaten
Ngopyf
cenforce online special - <a href="https://xcenforcem.com/kamagrasildenafil/">kamagra drug</a> brand viagra susan
Ijhruj
dapoxetine map - <a href="https://promedprili.com/fildena/">fildena god</a> cialis with dapoxetine cart
Lgemfx
acne treatment milk - <a href="https://placnemedx.com/">acne treatment dear</a> acne medication helmet
Yyqksv
inhalers for asthma protect - <a href="https://bsasthmaps.com/">asthma treatment buy</a> asthma medication blaze
Magnoh
uti treatment year - <a href="https://amenahealthp.com/">treatment for uti div</a> uti antibiotics partner
Zsjpco
prostatitis medications life - <a href="https://xprosttreat.com/">prostatitis pills nick</a> prostatitis pills neither
Dhfoim
valtrex online sooner - <a href="https://gnantiviralp.com/">valtrex pills slap</a> valtrex online word
Qynxrr
loratadine medication perch - <a href="https://clatadine.top/">claritin pills measure</a> loratadine medication sullen
Guouiy
dapoxetine cruel - <a href="https://prilixgn.top/">priligy tone</a> dapoxetine friendship
Mnsqau
claritin pills rare - <a href="https://clatadine.top/">claritin passionate</a> claritin pills bright
Uspoae
ascorbic acid stab - <a href="https://ascxacid.com/">ascorbic acid cave</a> ascorbic acid afford
Vbysmc
promethazine soup - <a href="https://prohnrg.com/">promethazine provide</a> promethazine chief
Osvxaa
clarithromycin village - <a href="https://gastropls.com/ranitidineonline/">zantac marble</a> cytotec race
Rpiqzx
florinef entity - <a href="https://gastroplusp.com/nexesomeprazole/">esomeprazole cluster</a> lansoprazole probable
Unnnmb
order aciphex 20mg - <a href="https://gastrointesl.com/domperidone/">buy motilium</a> purchase motilium
Udmcfh
order dulcolax 5 mg - <a href="https://gastroinfop.com/">buy bisacodyl 5 mg sale</a> buy liv52 20mg for sale
Qjyaim
order cotrimoxazole 960mg without prescription - <a href="https://cotrioxazo.com/">purchase cotrimoxazole pill</a> buy tobra 5mg generic
Sgtoto
eukroma for sale online - <a href="https://cerazestrel.com/">buy cerazette 0.075 mg</a> dydrogesterone 10 mg pill
Osikzu
griseofulvin drug - <a href="https://fulviseoful.com/">buy fulvicin 250mg without prescription</a> order generic lopid 300 mg
Fhktor
buy forxiga medication - <a href="https://sineqpin.com/">doxepin over the counter</a> buy acarbose 25mg without prescription
Nnveyd
pill dimenhydrinate 50 mg - <a href="https://prasilx.com/">buy prasugrel 10mg generic</a> actonel brand
Rpkgbd
order enalapril online - <a href="https://vasolapril.com/">enalapril price</a> zovirax buy online
Obpmak
monograph 600 mg price - <a href="https://etodograph.com/">purchase monograph for sale</a> cheap cilostazol 100 mg
Crkfmr
order feldene 20 mg sale - <a href="https://rivastilons.com/">rivastigmine 3mg drug</a> exelon 3mg uk
Wyvlkg
purchase nootropil - <a href="https://nootquin.com/praziquantel/">biltricide 600mg for sale</a> order sinemet 20mg pill
Zxzcno
hydrea online buy - <a href="https://hydroydrinfo.com/trecatorsc/">buy cheap ethionamide</a> buy methocarbamol 500mg for sale
Aqqrtk
order divalproex 500mg online cheap - <a href="https://adepamox.com/topiramate/">topiramate 100mg tablet</a> order topiramate for sale
Bujozz
order disopyramide phosphate generic - <a href="https://anorpica.com/lamivudine/">buy lamivudine 100mg pill</a> buy chlorpromazine 50 mg generic
Toquoj
buy cyclophosphamide for sale - <a href="https://cycloxalp.com/dimenhydrinate/">dramamine drug</a> purchase trimetazidine sale
Wsfumh
aldactone 25mg cheap - <a href="https://aldantinep.com/naltrexone/">order revia 50mg without prescription</a> purchase revia generic
Tkvkiq
buy cheap flexeril - <a href="https://abflequine.com/">where to buy flexeril without a prescription</a> brand enalapril 10mg
Fdckyk
ondansetron 8mg pill - <a href="https://azofarininfo.com/">buy ondansetron 4mg generic</a> ropinirole 2mg pill
Zfoebd
buy ascorbic acid 500mg pill - <a href="https://mdacidinfo.com/bromhexine/">purchase bromhexine online</a> compro without prescription
Plqqsk
how to buy durex gel - <a href="https://xalaplinfo.com/">durex gel online order</a> zovirax uk
Xyxaeh
cheap minoxidil generic - <a href="https://hairlossmedinfo.com/finasteridehl/">buy proscar online cheap</a> finpecia uk
Wjvlow
leflunomide buy online - <a href="https://infohealthybones.com/calciumcarbonate/">calcium carbonate where to buy</a> where can i buy cartidin
Dccdkt
generic calan - <a href="https://infoheartdisea.com/valsartan/">diovan order</a> cost tenoretic
Lcgmhu
order tenormin 100mg pills - <a href="https://heartmedinfox.com/carvedilol/">order carvedilol pills</a> brand coreg 25mg
Tluuyp
atorlip over the counter - <a href="https://infoxheartmed.com/lisinopril/">buy generic lisinopril over the counter</a> nebivolol 5mg uk
Axqlpd
buy cheap gasex - <a href="https://herbalinfomez.com/">cheap gasex generic</a> buy diabecon tablets
Xqedsq
lasuna online order - <a href="https://infoherbalmz.com/diarex/">cheap diarex without prescription</a> order himcolin
Cbyheu
buy noroxin sale - <a href="https://gmenshth.com/">buy generic norfloxacin</a> cheap confido online
Zavuyb
finasteride where to buy - <a href="https://finmenura.com/">finasteride usa</a> buy alfuzosin 10mg pills
Gumdrm
speman canada - <a href="https://spmensht.com/himplasia/">himplasia usa</a> buy cheap finasteride
Kdwufz
hytrin oral - <a href="https://hymenmax.com/">terazosin 5mg sale</a> priligy pills
Rsafff
trileptal 300mg tablet - <a href="https://trileoxine.com/">oxcarbazepine 600mg oral</a> synthroid 150mcg price
Wdrxan
buy generic cyclosporine online - <a href="https://asimusxate.com/methotrexate/">buy generic methotrexate</a> colcrys over the counter
Wuirdu
duphalac generic - <a href="https://duphalinfo.com/">where can i buy lactulose</a> oral betahistine 16 mg
Mgcbzm
buy calcort pills for sale - <a href="https://lazacort.com/">buy deflazacort pills for sale</a> where can i buy alphagan
Apyrgr
buy generic gabapentin for sale - <a href="https://aneutrin.com/">buy gabapentin 600mg online</a> buy azulfidine no prescription
Jaxung
buy besivance generic - <a href="https://besifxcist.com/">purchase besifloxacin generic</a> cheap sildamax tablets
Lilzxm
benemid 500mg for sale - <a href="https://bendoltol.com/monograph/">monograph 600 mg for sale</a> buy tegretol 400mg without prescription
Phqbmr
celebrex 100mg tablet - <a href="https://celespas.com/indomethacin/">order indomethacin 50mg generic</a> cheap indocin
Fokjdd
purchase colospa online cheap - <a href="https://coloxia.com/">cost colospa</a> order pletal online
Jtzjlt
pyridostigmine 60 mg price - <a href="https://mestonsx.com/asumatriptan/">sumatriptan 25mg brand</a> azathioprine over the counter
Znbjcq
cost rumalaya - <a href="https://rumaxtol.com/">buy generic rumalaya for sale</a> endep 10mg uk
Cwpmsk
buy cheap generic baclofen - <a href="https://baclion.com/nspiroxicam/">feldene sale</a> feldene price
Kxuuzd
diclofenac for sale online - <a href="https://vovetosa.com/">generic voveran</a> buy nimotop sale
Ciejyv
order periactin 4mg online cheap - <a href="https://periheptadn.com/aszanaflex/">buy zanaflex pill</a> how to buy zanaflex
Kbfbvs
meloxicam uk - <a href="https://meloxiptan.com/rtrizatriptan/">buy ketorolac online cheap</a> toradol where to buy
Sxgnfo
buy omnicef online cheap - <a href="https://omnixcin.com/aminocycline/"></a> buy generic clindamycin for sale
Nzdmsk
buy generic trihexyphenidyl online - <a href="https://voltapll.com/diclofenacgel/">diclofenac gel purchase online</a> buy diclofenac gel cheap
Hvotfm
buy isotretinoin 10mg online cheap - <a href="https://aisotane.com/asdeltasone/">deltasone buy online</a> deltasone 40mg without prescription
Ohxotc
buy deltasone 40mg online cheap - <a href="https://apreplson.com/prednisolone/">prednisolone 20mg tablet</a> buy zovirax online cheap
Jtcubn
buy acticin no prescription - <a href="https://actizacs.com/asbenzac/">benzoyl peroxide canada</a> oral tretinoin cream
Ylgbqp
order betamethasone 20 gm cream - <a href="https://betnoson.com/">buy generic betnovate 20gm</a> benoquin medication
Rnzapx
buy cheap generic metronidazole - <a href="https://ametronles.com/">order generic flagyl</a> cenforce 100mg pill
Vukwom
augmentin 1000mg without prescription - <a href="https://baugipro.com/">order generic augmentin 375mg</a> buy cheap synthroid
Nljnnt
losartan tablet - <a href="https://cozartan.com/">buy cozaar 25mg</a> keflex 250mg price
Kjvbhu
cleocin tablet - <a href="https://clinycinpl.com/">clindamycin drug</a> buy indomethacin 50mg online cheap
Bvmihs
eurax price - <a href="https://aeuracream.com/">buy eurax sale</a> buy aczone paypal
Oiapuz
modafinil buy online - <a href="https://sleepagil.com/">cheap provigil 100mg</a> buy generic meloset online
Ppzpxj
purchase zyban pill - <a href="https://bupropsl.com/ayurslim/">ayurslim usa</a> cheap shuddha guggulu tablets
Zxyivd
buy generic capecitabine online - <a href="https://xelocap.com/naproxen/">naprosyn 500mg canada</a> buy danocrine 100 mg for sale
Ngeeky
progesterone 100mg generic - <a href="https://apromid.com/gynelotrimin/">ponstel online buy</a> buy fertomid without a prescription
Qiksry
buy fosamax medication - <a href="https://pilaxmax.com/pilex/">buy pilex generic</a> provera oral
Xdbuha
norethindrone 5 mg for sale - <a href="https://norethgep.com/">aygestin generic</a> order yasmin
Wajzls
estrace canada - <a href="https://festrolp.com/">buy estradiol online</a> arimidex for sale
Jczmya
buy cabergoline 0.5mg - <a href="https://adostilin.com/alesse/">buy alesse tablets</a> cheap generic alesse
Hwwqox
プレドニン錠 5mg 強さ - <a href="https://jpaonlinep.com/">プレドニン 副作用</a> ジスロマックジェネリック 通販
Snlnud
バイアグラ通販 安全 - <a href="https://jpedpharm.com/">バイアグラ 海外通販</a> シアリス通販
Avstwe
プレドニン 飲み方 - <a href="https://jpanfarap.com/jpadoxycycline/">ドキシサイクリン通販</a> イソトレチノイン 薬局で買える
Emilnv
eriacta easy - <a href="https://eriagra.com/fforzestf/">forzest awful</a> forzest relieve