Commit d4370073 by jscat

nyx: map模块

为地图添加scale和translate支持
parent 4bec0105
var config = wx.getStorageSync("config");
var config = wx.getStorageSync("config");
......@@ -194,8 +194,9 @@ Page({
var deltaT = self.imgTop - imgPos.top
//step3: 计算tag初始坐标:
// x向右,y向右; center为可视区域center
// x向右,y向右; center为可视区域左上角
var initPos = genInitPos(self, scaleL-deltaL, scaleT-deltaT, newScale)
var initPosRatio = genInitPosRatio(self, initPos)
var strUrl = config.msg_add_url
var tmp = {
id: "",
......@@ -203,8 +204,8 @@ Page({
address: "",
textL: scaleL,
textT: scaleT,
initTextL: initPos.initL,
initTextT: initPos.initT,
initTextL: initPosRatio.initL,
initTextT: initPosRatio.initT,
}
allText.push(tmp)
......@@ -457,19 +458,14 @@ Page({
var result = {}
result["id"] = res.data.data[i].id
result["name"] = res.data.data[i].memberName
var textL = parseFloat(res.data.data[i].posLeft * 2 / _this.initRatio + initImgLeft)
var textT = parseFloat(res.data.data[i].posTop * 2 / _this.initRatio + initImgTop)
console.log(_this)
console.log("left_" + initImgLeft)
console.log("top_" + initImgTop)
console.log("textL_" + textL)
console.log("textT_" + textT)
var textL = parseFloat(res.data.data[i].posLeft * _this.initWidth * 2 / _this.initRatio + initImgLeft)
var textT = parseFloat(res.data.data[i].posTop * _this.initHeight * 2 / _this.initRatio + initImgTop)
result["textL"] = textL
result["textT"] = textT
result["address"] = res.data.data[i].memberAddress
//load from db, in rpx format
result["initTextL"] = textL
result["initTextT"] = textT
result["initTextL"] = parseFloat(res.data.data[i].posLeft)
result["initTextT"] = parseFloat(res.data.data[i].posTop)
list.push(result)
}
......@@ -826,7 +822,9 @@ function drawOnTouchMove(self, e) {
var textPos = {}
for (let i = 0; i < allText.length; i++) {
//step3: 计算tag点新坐标 in px
textPos = genScalePos(self, allText[i].initTextL, allText[i].initTextT, newScale)
var textL = parseFloat(allText[i].initTextL * self.initWidth * 2 / self.initRatio + initImgLeft)
var textT = parseFloat(allText[i].initTextT * self.initHeight * 2 / self.initRatio + initImgTop)
textPos = genScalePos(self, textL, textT, newScale)
// step4新的tag点坐标
allText[i].textL = textPos.left + deltaL
......@@ -867,4 +865,17 @@ function genInitPos(self, scaleL, scaleT, scale) {
return { initL, initT }
}
/*
通过平移+缩放后的坐标转为初始坐标
*/
function genInitPosRatio(self, initPos) {
var tmpL = (initPos.initL -self.data.initImgLeft)*self.initRatio/2
var tmpT = (initPos.initT - self.data.initImgTop) * self.initRatio / 2
var initL = (tmpL/self.initWidth).toFixed(4)
var initT = (tmpT / self.initHeight).toFixed(4)
return { initL, initT }
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论