首页 > 其他分享 >3/30每日总结:地图下钻功能的实现

3/30每日总结:地图下钻功能的实现

时间:2023-03-30 23:02:04浏览次数:27  
标签:总结 info function 30 地图 intent mySubway btn id

在main中新建

 

然后导入html文件

其中代码如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!--重要meta, 必须!-->
    <meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,shrink-to-fit=no" />
    <title>SUBWAY</title>
</head>
<body>
<div id="mybox"></div>
<script src="https://webapi.amap.com/subway?v=1.0&key=b09132fa0d59581435755699c411c397&callback=cbk"></script>
<script type="text/javascript">
    window.cbk = function() {
        var mySubway = subway("mybox", {
            adcode: 1100,
            theme: "colorful",
            client: 0,
            doubleclick: {
                switch: true
            }
        });
        //地铁加载完成,执行complete事件
        mySubway.event.on("subway.complete", function(ev, info) {
            var id = info.id;
        });

        //点击站点,显示此站点的信息窗体
        mySubway.event.on("station.touch", function(ev, info) {
            var id = info.id;
            mySubway.stopAnimation();
            mySubway.addInfoWindow(id, {});
            var center = mySubway.getStCenter(id);
            mySubway.setCenter(center);
        });

        //点击线路名,高亮此线路
        mySubway.event.on("lineName.touch", function(ev, info) {
            mySubway.showLine(info.id);
            var select_obj = qs('#g-select');
            mySubway.setFitView(select_obj);
            var center = mySubway.getSelectedLineCenter();
            mySubway.setCenter(center);
        });

        //点击空白, 关闭infowindow
        mySubway.event.on("subway.touch", function() {
            mySubway.clearInfoWindow();
        });

        //设置起点
        mySubway.event.on("startStation.touch", function(ev, info) {
            mySubway.stopAnimation();
            mySubway.clearInfoWindow();
            mySubway.setSt
            art(info.id, {});
            startInfo = info;
            route();
        });

        //设置终点
        mySubway.event.on("endStation.touch", function(ev, info) {
            mySubway.stopAnimation();
            mySubway.clearInfoWindow();
            mySubway.setEnd(info.id, {});
            endInfo = info;
            route();
        });

        //路线规划
        var startInfo = {},
            endInfo = {};
        function route() {
            if (startInfo.id && endInfo.id) {
                mySubway.route(startInfo.id, endInfo.id, {});
                startInfo = {};
                endInfo = {};
            }
        }
    };
</script>
</body>

  这个key的值可能不一样可能需要改。

MainActivity代码:

package com.example.chaxun;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.example.chaxun.Dao.Dao;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Dao Dao = new Dao();
    private Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_selectbyline).setOnClickListener(this);
        findViewById(R.id.btn_selectbystation).setOnClickListener(this);
        findViewById(R.id.btn_selectbetween).setOnClickListener(this);
        findViewById(R.id.btn_ditu).setOnClickListener(this);
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_selectbyline:
                intent = new Intent(MainActivity.this, SearchLineActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_selectbystation:
                intent = new Intent(MainActivity.this, SearchStationActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_selectbetween:
                intent = new Intent(MainActivity.this, ChangeStationActivity.class);
                startActivity(intent);
                break;
                case R.id.btn_ditu:
                intent = new Intent(MainActivity.this, MapActivity.class);
                startActivity(intent);
                break;
        }
    }

}

  xml中的代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity">

    <!--    <TextView-->
    <!--        android:layout_width="wrap_content"-->
    <!--        android:layout_height="wrap_content"-->
    <!--        android:text="Hello World!"-->
    <!--        app:layout_constraintBottom_toBottomOf="parent"-->
    <!--        app:layout_constraintLeft_toLeftOf="parent"-->
    <!--        app:layout_constraintRight_toRightOf="parent"-->
    <!--        app:layout_constraintTop_toTopOf="parent" />-->


    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/mWebView">
    </WebView>

</androidx.constraintlayout.widget.ConstraintLayout>

  这样就能实现地图下钻的功能了

 

标签:总结,info,function,30,地图,intent,mySubway,btn,id
From: https://www.cnblogs.com/nanbei666/p/17274689.html

相关文章

  • 总结三次题目集的知识点、题量、难度等情况
    前言:题目集1是Java入门,大至涵盖了Java的几种基本语言结构,如循环,选择,数组。与c语言大致相似,上手较容易。但是题目难度不低,7-10GPS数据处理,不仅题目长难以理解,对有难度的字符串要求掌握熟练,输出要考虑的情况也很多,题目也达12题之多。其他题目在c语言里写过近似一模一样的题,写这个题......
  • python基础学习总结
    python关键字也是以下划线或者字母开头。python关键字可以通过导包获取关键字如下: ['False','None','True','and','as','assert','async','await','break','class','continue'......
  • 每日总结2023-03-30
    今天完成了部分个人界面成果: 实现了fragment跳转到Activity,对于导航栏的颜色变化仍有不懂,对于地图的预加载、实现仍不会实现。登录功能可以实现但未完成。 ......
  • 3.30App端地铁查询 设计思路 源程序代码、运行结果截图、编程总结分析。
    App端地铁查询设计思路源程序代码、运行结果截图、编程总结分析。 关于地铁查询App的设计思路。设计思路:我们沿用pc端的数据库设计结构,减少了我们的工作量。查询方法以及设计思路都很javaweb设计的大同小异。在设计中我们遇到的主要问题就是安卓Studio中的mysql数据库的......
  • 每日总结 3.30
    今天继续学习了微信小程序的开发,做了一个页面,如下: 代码量大概100行。继续为外包杯学习小程序。 ......
  • 每日总结2023/3/25
    前期我们已经找到了目标客户的需求,精准定位了目标顾客最强烈的痛点,如何解决客户的问题?如何能让客户接受你的解决方案?购买你的产品?精益产品开发——Stage-Fit的第二个阶段:方案阶段,告诉我们如何做出最有效的解决方案——你需要不断迭代你的解决方案,不断试错,直到它是最完美的那一个。......
  • 3.30软件工程学习总结
    今天由于课程较多,没有较多的时间学代码,但也有点时间基本上完成了团队外包杯项目的简单的展示页面设计制作。今天还思考了,觉得自己差的还是挺多的,以后在完成了团队内我能完成的任务后,在可利用的时间里还是要学习更多的内容,学习别人做的部分。......
  • 2023-03-30-链栈LinkStack的实现
    1#include<stdio.h>2#include<malloc.h>34typedefstructSNode5{6intdata;7structSNode*next;8}SNode,*LinkStack;9//栈的主要操作是在栈顶进行插入和删除,所以将链表的头部看为栈顶最合适10voidinitLinkStack(LinkStackS)//初始化1......
  • 每日总结-23.3.29-利于云服务器和javaweb简单实现一个网站
    每日总结-23.3.29-利于云服务器和javaweb简单实现一个网站 3月29日总结今日使用云服务器和tomcat实现了简单网站的搭建。使用工具(个人体验,仅作参考,使用其他版本或工具应该也行):1.移动云新人体验免费云服务器一台。(个人专享:通用型云主机)活动页面 (https://ecloud.10086.......
  • App端地铁查询 设计思路 源程序代码、运行结果截图、编程总结分析。
    关于地铁查询App的设计思路。设计思路:我们沿用pc端的数据库设计结构,减少了我们的工作量。查询方法以及设计思路都很javaweb设计的大同小异。在设计中我们遇到的主要问题就是安卓Studio中的mysql数据库的连接。(查询数据库时主线程与子线程冲突的问题解决)查询大致分为三大类:一:线......