51地图开发中如何在js中传参

李世荣 2012-04-16 10:24:00
先看代码:
$(document).ready(function(){
var map; //地图对象
var mapEditor; //地图编辑对象
var markerEditor; //标注点编辑对象
map=new LTMaps("myMap");
map.cityNameAndZoom( "beijing" , 10);
map.addControl(new LTStandMapControl());
//拉框放大控件
var control = new LTZoomInControl();
map.addControl( control );
//添加缩放控件
var control1 = new LTStandMapControl();
map.addControl( control1 );
//设置标注图标样式
var icon = new LTIcon();
icon.setImageUrl( "images/bluepoint.png" );
icon.setWidth( 10 );
icon.setHeight( 10 );
//添加标注点
var pointSets=getPointSets();
var points=pointSets.split("*&^,");
for(var i=0;i<points.length;i++){
var point=points[i].split(",^&*");
var diary_Id=point[0];
var title=point[1];
var lat=point[2];
var lon=point[3];
var marker = new LTMarker( new LTPoint(lon,lat),icon);
map.addOverLay( marker);
LTEvent.bind(marker,"click",marker,clickInformation); function clickInformation(){
alert("test");
}
}
});

红色的那句,如果我想吧lat,lon这些要素传到clickInformation()函数中进行显示,不知道怎么个传法。主要是51地图的传递规则不一样。这样子我在地图中每点击一个点就能够显示对应的信息了。
...全文
71 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
装逼之王 2012-04-17
  • 打赏
  • 举报
回复
查看官方文档!具体问题具体分析
在尝试开发了一个微信小程序之,后发现有mpvue这么个东西可以来开发小程序以后就忍不住了,所以把小程序和我用vue开发过的版本结合修改以后,再尝试用mpvue iview-weapp开发一个版本。后台接口用的是NeteaseCloudMusicApi,感谢大佬的分享git地址,demo项目代码质量不是很好,哈哈哈哈多多见谅预览(不动点大图看)目前完成推荐歌单排行榜歌单详情播放页歌单评论搜索扫一扫(基础功能)周边(百度地图api)项目搭建最开始还是要把微信小程序开发工具下载一下mpvue项目建立,跟着官网走一遍是最快的 快速上手支持iview-weapp,还是跟着官网快速上手,这里就一个地方要注意,把下载下来的iview-weapp项目的dist文件夹(可以改名字)是放到你项目编译后的dist目录下,iview-weapp官网没有效果的展示,所以建议扫它上面的二维码查看效果以后对照它的代码进行开发最后就是用微信小程序开发工具打开项目(不是dist目录),用你常用的编译器编写代码(src目录下)请求方面微信小程序有自带的wx.request()可以使用,还可以用Flyio,我是用的Flyio具体使用的话可以再每个模块var Fly=require("flyio/dist/npm/wx") var fly=new Fly fly.get(url).then(res=>{})还有就是在main.jsconst Fly = require('flyio/dist/npm/wx'); let fly = new Fly(); Vue.prototype.$fly = fly; //模块使用  this.$fiy.get(url).then(res=>{})路由跳转传参wx.navigateTo({url:'../test/main?id=' id})\u7b2c\u4e00\u79cd\uff1aonShow\u00a0(options)\u00a0{\r\n\r\nlet\u00a0id\u00a0=\u00a0options.id\r\n\r\n}\u7b2c\u4e8c\u79cd\uff1a\u5728\u6240\u6709\u9875\u9762\u7ec4\u4ef6\u5185\u53ef\u4ee5\u901a\u8fc7 this.$root.$mp.query \u83b7\u53d6,\u8981\u6ce8\u610f\u5c31\u662f\uff1a\u5199\u5728mounted\u51fd\u6570\u91cc\uff0c\u5199\u5230created\u62a5\u9519\u3002\u7b2c\u4e09\u79cd\uff1a\u5728\u6240\u6709\u7684\u7ec4\u4ef6\u5185\u53ef\u4ee5\u901a\u8fc7 this.$root.$mp.appOptions\u83b7\u53d6\u3002\u6b63\u5e38\u60c5\u51b5\u4e0b\u4e09\u79cd\u5e94\u8be5\u90fd\u662f\u53ef\u4ee5\u7684\uff0c\u67d0\u4e00\u79cd\u6ca1\u7528\u7684\u65f6\u5019\u5c31\u5c1d\u8bd5\u53e6\u5916\u4e24\u79cd\u65b9\u9762\u8fd8\u662f\u548cvue\u91cc\u9762\u7684\u4f7f\u7528\u4e00\u6837\uff0c\u7b80\u5355\u7684/src/store/store.jsimport\u00a0Vue\u00a0from\u00a0'vue' import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex.Store({   state: {    oneState:'one'     }   },   mutations: {     setItem: (state,data) => {       state.oneState = data     },   },   getters : {     getItem (state) {         return state.oneState     }, });/src/main.jsimport store from './store/store' Vue.prototype.$store = store;/src/page/text.vueimport {mapGetters} from 'vuex'   export default {      computed:{        ...mapGetters([          'oneState'         ])      },      },      methods:{          test(){              this.$store.commit('setItem', 'two')          }      }总结好了,基本的开发流程就是这样,具体的开发大部分还是像vue开发那样,自己在开发的时候,遇到的坑还是有的,但网上基本都能找到解决方案,具体遇到的时候就查一查都能查到,收获很多。 最后这里还有一个用vue开发的版本可在线预览,建议用chrome的手机模式预览

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧