|
本帖最后由 biyaooo 于 2015-4-12 19:57 编辑
和之前登录实例一样,代码我不会写, 引用了起步sxl提供的代码,我应用到了我的APP ,这里只是分享下,供更多新手学习。
效果图:
test.w 源码- <?xml version="1.0" encoding="utf-8"?>
- <div xmlns="http://www.w3.org/1999/xhtml" component="$UI/system/components/justep/window/window" class="window portal-main" xid="window" design="device:m;">
- <div component="$UI/system/components/justep/model/model" xid="model" style="height:auto;left:19px;top:450px;" onLoad="modelLoad">
- </div>
- <div component="$UI/system/components/justep/panel/panel" class="x-panel x-full" xid="panel1">
- <div class="x-panel-top" xid="top1">
- <div component="$UI/system/components/justep/titleBar/titleBar" class="x-titlebar"
- xid="titleBar" title="APP应用" style="background-color:black;">
- <div class="x-titlebar-left" xid="div1">
- <a component="$UI/system/components/justep/button/button" class="btn btn-link"
- xid="menuBtn" icon="icon-navicon-round">
- <i xid="i1" class="icon-navicon-round"/>
- <span xid="span1"/>
- </a>
- </div>
- <div class="x-titlebar-title" xid="div2">APP应用</div>
- <div class="x-titlebar-right reverse" xid="div3"/>
- </div>
- </div>
- <div class="x-panel-content" xid="content1"><div component="$UI/system/components/justep/contents/contents" class="x-contents x-full" active="1" xid="contents1" slidable="false">
- <div class="x-contents-content" xid="content2">
- </div>
- <div class="x-contents-content" xid="content3">
- </div>
- <div class="x-contents-content" xid="content4"></div>
- <div class="x-contents-content" xid="amapContainer" onActive="mapContainerActive"></div></div></div>
- <div class="x-panel-bottom" xid="bottom1"><div component="$UI/system/components/justep/button/buttonGroup" class="btn-group btn-group-justified" tabbed="true" xid="buttonGroup1" selected="gxHome">
- <a component="$UI/system/components/justep/button/button" class="btn x-black btn-icon-top btn-block" label="首页" xid="gxHome" target="content2" icon="icon-home">
- <i xid="i5" class="icon-home"></i>
- <span xid="span6">首页</span></a>
- <a component="$UI/system/components/justep/button/button" class="btn x-black btn-icon-top" xid="gxApp" target="content3" label="应用" icon="icon-social-tux">
- <i xid="i6" class="icon-social-tux"></i>
- <span xid="span7">应用</span></a>
- <a component="$UI/system/components/justep/button/button" class="btn x-black btn-icon-top" label="测试" xid="gxStudy" target="content4" icon="icon-android-contacts">
- <i xid="i7" class="icon-android-contacts"></i>
- <span xid="span8">测试</span></a>
- <a component="$UI/system/components/justep/button/button" class="btn x-black btn-icon-top" label="地图" xid="gxShop" target="amapContainer" icon="icon-chatbubbles">
- <i xid="i8" class="icon-chatbubbles"></i>
- <span xid="span9">地图</span></a> </div></div></div></div>
复制代码
test.js 代码
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
-
- var Model = function(){
- this.callParent();
- };
- Model.prototype.modelLoad = function(event){
- };
- Model.prototype.mapContainerActive = function(event){ //页面激活才加载地图
- if (!this.mapLoaded) { //控制只加载一次
- var self = this;
- require([ "http://webapi.amap.com/maps?v=1.3&key=ff582fb8e3843cb4fa53ce591411378c" ], function() {
- var mapObj = new AMap.Map(self.getIDByXID("amapContainer"), { //通过XID来获取地图对象识别的ID值的加载容器
- view : new AMap.View2D({
- zoom : 14,
- rotation : 0
- }),
- lang : "zh_cn"// 设置语言类型,中文简体
- });
- mapObj.plugin(['AMap.ToolBar'],function(){
- //设置地位标记为自定义标记
- var toolBar = new AMap.ToolBar();
- mapObj.addControl(toolBar);
- });
- });
- this.mapLoaded = true;
- };
- };
- return Model;
- });
复制代码
注:http://webapi.amap.com/maps?v=1. ... cb4fa53ce591411378c 为高德地图引入接口地址,key为自己的账号申请的开发key
申请好了以后,需要设置白名单才可以访问的,不然会提示出错。
引用百度的,更换这个地址就行了。对于的创建地图实例代码,百度官网的地图API有开发指南。
|
|