krpano使用总结-地图路线
生活随笔
收集整理的這篇文章主要介紹了
krpano使用总结-地图路线
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
全景圖中常用的功能點有:
1.皮膚定制,指定皮膚中icon的位置、圖片、樣式等
2.音頻的播放與暫停
3.地圖路線
4.添加logo或地標
5.點擊事件
此次總結地圖分享功能點,步驟如下:
1.在xml中引入高德地圖插件
<plugin name="nv" keep="true" devices="mobile" url="js/action.js"
desloc="39.9178540000,116.3970060000" desname="北京故宮"/>
2.在xml中寫地圖調用方法
<action name="naviToMap">plugin[nv].setdes(get(plugin[nv].desloc),get(plugin[nv].desname));plugin[nv].navigation(); </action> 復制代碼3.在xml中寫地圖iocn,配置oclick
<layer name="skin_btn_mymap" style="skin_base|skin_glow" crop="0|256|64|64" align="right" x="15" y="-250" scale="0.5" onclick="naviToMap();js(clickBury('travel_panorama_locate_click','travel_panorama_locate');)" /> 復制代碼4.編寫獲取當前位置、跳轉地圖js,當前位置的獲取需要注意,ios中僅支持https協議
var krpanoplugin = function () { var local = this; // save the 'this' pointer from the current plugin objectvar krpano = null; // the krpano and plugin interface objects var plugin = null;var plugincanvas = null; // optionally - a canvas object for graphic content var plugincanvascontext = null;// registerplugin - startup point for the plugin (required) // - krpanointerface = krpano interface object // - pluginpath = string with the krpano path of the plugin (e.g. "plugin[pluginname]") // - pluginobject = the plugin object itself (the same as: pluginobject = krpano.get(pluginpath) ) local.registerplugin = function (krpanointerface, pluginpath, pluginobject) {krpano = krpanointerface;plugin = pluginobject;// add a from xml callable functions:plugin.setdes=setdes;plugin.navigation=navigation; }var desLocation; var desName;function setdes(des,name) {desLocation=des;desName=name;//alert(desLocation);//alert(desName); }function navigation() {if (navigator.geolocation){if(isiOS){//從app端獲取定位信息(解決用戶拒絕定位后無法重新定位)var position = {coords:{longitude:"",latitude:""}};AHJavascriptBridge.invoke('fetchLocation',{},function(args,callback){position.coords.longitude = args.longitude;position.coords.latitude = args.latitude;showPosition(position);});}else{//自己獲取定位navigator.geolocation.getCurrentPosition(showPosition,showError);}}else{alert("Geolocation is not supported by this browser.");} }function showPosition(position) {var mapUrl = encodeURIComponent("http://m.amap.com/?from="+position.coords.latitude+","+position.coords.longitude+"(我的位置)&to="+desLocation+"("+desName+")&type=0");if(myversion==1){//安卓AHJavascriptBridge.invoke('goMap',{"url":mapUrl,"title":"從我的位置到"+desName});}else{//M端window.location.href="http://m.amap.com/?from="+position.coords.latitude+","+position.coords.longitude+"(我的位置)&to="+desLocation+"("+desName+")&type=0";}}function showError(error) {switch(error.code){case error.PERMISSION_DENIED:alert("請在手機設置里修改定位權限");break;case error.POSITION_UNAVAILABLE:alert("Location information is unavailable.");break;case error.TIMEOUT:x.innerHTML=alert("The request to get user location timed out.");break;case error.UNKNOWN_ERROR:alert("An unknown error occurred.");break;} }// unloadplugin - end point for the plugin (optionally) // - will be called from krpano when the plugin will be removed // - everything that was added by the plugin (objects,intervals,...) should be removed here local.unloadplugin = function () {plugin = null;krpano = null; } 復制代碼};
總結
以上是生活随笔為你收集整理的krpano使用总结-地图路线的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: unity节目素材ProceduralM
- 下一篇: Android 让图片等比例缩放的三种方