<!DOCTYPE html>
<html>
<head >
<meta charset="utf-8">
<script src="../../js/jquery-1.9.1.min.js"></script>
<script src="../../js/highmaps/highmaps.js"></script>
<script src="../../js/highmaps/drilldown.js"></script>
<script src="../../js/highmaps/exporting.js"></script>
</head> <body>
<!--<div id="container" style="height:450px;"></div>-->
<script type="text/javascript"> Highcharts.setOptions({
lang: {
drillUpText: '< 返回 “{series.name}”'
}
});
var map = null,
// geochina = 'https://data.jianshukeji.com/jsonp?filename=geochina/';
// $.getJSON(geochina + 'china.json&callback=?', function(mapdata) {//中国//https://jshare.com.cn/highmaps/FSSm7A //https://data.jianshukeji.com/
// geochina = 'http://192.168.0.62:8082/';
geochina = 'http://192.168.0.62:8082/jsonp/geo?filename=';
$.getJSON(geochina + 'zhejiang.json&callback=?', function(mapdata) {//浙江
//地图数据 https://data.jianshukeji.com/jsonp?filename=geochina/zhejiang/hangzhou.json
//地图数据 https://data.jianshukeji.com/jsonp?filename=geochina/zhejiang.json
var data = [];
// 随机数据
Highcharts.each(mapdata.features, function(md, index) {
var tmp = {
name: md.properties.name,
value: Math.floor((Math.random() * 100) + 1) // 生成 1 ~ 100 随机值
};
if(md.properties.drilldown) {
tmp.drilldown = md.properties.drilldown;
}
data.push(tmp);
});
map = new Highcharts.Map('container', {
chart: {
events: {
drilldown: function(e) {
this.tooltip.hide();
console.log(e);
// 异步下钻
if (e.point.drilldown) {
var pointName = e.point.properties.fullname;
map.showLoading('下钻中,请稍后...');
// 获取二级行政地区数据并更新图表
console.dir(geochina);
$.getJSON(geochina + e.point.drilldown + '.json&callback=?', function(data) {
// $.getJSON(url, function(data) {
data = Highcharts.geojson(data);
Highcharts.each(data, function(d) {
if(d.properties.drilldown) {
d.drilldown = d.properties.drilldown;
}
d.value = Math.floor((Math.random() * 100) + 1); // 生成 1 ~ 100 随机值
});
map.hideLoading();
map.addSeriesAsDrilldown(e.point, {
name: e.point.name,
data: data,
dataLabels: {
enabled: true,
format: '{point.name}'
}
});
map.setTitle({
text: pointName
});
});
}
},
drillup: function() {
map.setTitle({
text: '浙江省'
});
}
}
},
title: {
text: '浙江省'
},
subtitle: {
useHTML: true,
// text: '点击查看 <a href="https://www.hcharts.cn/mapdata" target="_blank">地图数据及详情</a>,注意县级数据为收费数据,如果您有需要,请 <a href="https://highcharts.com.cn/data" target="_blank">联系我们购买</a>'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
tooltip: {
useHTML: true,
headerFormat: '<table><tr><td>{point.name}</td></tr>',
pointFormat: '<tr><td>全称</td><td>{point.properties.fullname}</td></tr>' +
'<tr><td>行政编号</td><td>{point.properties.areacode}</td></tr>' +
'<tr><td>父级</td><td>{point.properties.parent}</td></tr>' +
'<tr><td>经纬度</td><td>{point.properties.longitude},{point.properties.latitude}</td></tr>' ,
footerFormat: '</table>'
},
// colorAxis: {
// min: 0,
// minColor: '#fff',
// maxColor: '#006cee',
// labels:{
// style:{
// "color":"red","fontWeight":"bold"
// }
// }
// },
series: [{
data: data,
mapData: mapdata,
joinBy: 'name',
name: '浙江省',
states: {
hover: {
color: '#a4edba'
}
}
}]
});
});
</script>
<div id="container" style="height:850px;"></div> </body>
</html> 、、、、、、、、、、、、、、、、、、、、、 后端:
package com.hzunitech.platform.mvc.jsonp;

import com.hzunitech.platform.annotation.Controller;
import com.hzunitech.platform.mvc.base.BaseController;
import com.jfinal.log.Log; @Controller("/jsonp")
public class JsonpController extends BaseController { @SuppressWarnings("unused")
private static final Log log = Log.getLog(JsonpController.class); public void index() {
// 客户端请求参数,js函数名称
String jsonpCallback = getPara("callback"); // json数据
String json = "{'content':'我是远程b.com/remote.js带来的数据'}"; // 返回jsonp格式数据
//jquery定义了名为jsonpCallback的js函数,在渲染返回的javascript text时执行了该函数,并将数据结果作为参数传入该js函数
renderJavascript(jsonpCallback + "(" + json + ");");
} public void geo() {
// 客户端请求参数,js函数名称
String jsonpCallback = getPara("callback");
log.info(jsonpCallback);
System.out.println(jsonpCallback); // json数据
String json = "{'content':'我是远程b.com/remote.js带来的数据'}"; // 返回jsonp格式数据
renderJavascript(jsonpCallback + "(" + json + ");");
} }
												

jquery的jsonp相关的更多相关文章

  1. jquery之jsonp相关知识

    这里讲的不错,可以参考:链接 我自己的理解: 服务器为了保证数据的安全,同时也为了保证不被攻击, 凡是来服务器请求的url,域名必须和服务器一致,否则就是跨域请求 为了解决跨域问题,就出现了jsonp ...

  2. 使用springMVC和Jquery实现JSONP

    JSONP这个东东是啥我就不写了,直接贴实现的代码 JAVA代码: /** * * 查询用户是否已经提交认证获取已经是认证会员 * * 使用spring mvc的直接返回string会遇到分号转义后字 ...

  3. jQuery处理JSONP

    http://www.g7blogs.com/?p=821 作为一枚前端,提起jsonp大家都不会陌生.特别是在我们组内的业务中,和服务器端交互的数据几乎都是采用这种形式.但假如要让你用原生的JS写出 ...

  4. jQuery 调用jsonp实现与原理

    jQuery 调用jsonp实现与原理 您的评价:        收藏该经验     阅读目录 1.客户端代码 2.服务器端 通过jQuery实现JSONP 一般的ajax是不能跨域请求的,因此需要使 ...

  5. jQuery的jsonp跨域是这么回事.

    实现跨域请求的有iframe,img,script中的src属性.那么jquery是如何解决跨域请求的呢? 一:项目jsonp2中有个app.js文件,代码如下: function app(json) ...

  6. jquery ajax jsonp跨域调用实例代码

    今天研究了AJAX使用JSONP进行跨域调用的方法,发现使用GET方式和POST方式都可以进行跨域调用,这里简单分享下,方便需要的朋友 客户端代码 复制代码 代码如下: <%@ Page Lan ...

  7. 基于jQuery的Jsonp跨域[Get方式]

    由于目前的项目需要无刷新的跨域操作数据,整理了下自己使用的基于jQuery的Jsonp跨域[Get方式]. 代码如下: Javascript部分 $(function(){ $.ajax({ asyn ...

  8. jQuery中jsonp函数实现

    由于浏览器中的同源策略,不同的域名,不同的协议,甚至不同的端口都无法请求数据.因此出现了浏览器跨域请求数据问题. Jsonp是解决跨域问题的一个非常流行的方法. JSONP(JSON with Pad ...

  9. C# WebClient、jQuery ajax jsonp实现跨域

    WebClient 无传输数据获取 Uri uri = new Uri(allURL); WebClient wc = new WebClient(); wc.Encoding = System.Te ...

随机推荐

  1. linux系统常用命令 -设置文件夹读写权限

    设置文件夹的读写权限: sudo chmod -R 777 /data 权限码描述 sudo chmod 600 ××× (只有所有者有读和写的权限)sudo chmod 644 ××× (所有者有读 ...

  2. 阿里云Ubuntu部署java web - 文件夹

    文件夹(点击章节标题阅读): 阿里云Ubuntu部署java web(1) - 系统配置         ssh链接server(使用终端远程链接)        加入用户        给用户赋予运 ...

  3. linux 批量替换内容

    sed -i "s/被替换的内容/替换的内容/g" `grep "被替换的内容" -rl 目录` -r = 搜索下级目录

  4. UINavigationController 返回按钮去掉文字

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetric ...

  5. mysql 查询锁,解锁语句

    一:锁表: 锁定数据表,避免在备份过程中,表被更新 mysql>LOCK TABLES tbl_name READ; 为表增加一个写锁定: mysql>LOCK TABLES tbl_na ...

  6. Missing iOS Distribution signing identity for …, 在打包的时候发现证书过期了。

    今天早上 上班发现钥匙串中的全部证书 都 提示此证书签发者无效 Thanks for bringing this to the attention of the community and apolo ...

  7. 蓝牙(CoreBluetooth)-中心设备(客户端)

    蓝牙(CoreBluetooth)-中心设备(客户端) 蓝牙客户端-中心设备 主要内容 1. 创建`中央管理器` 2. 发现并且连接外设 3. 寻找连接上的外设数据 4. 发送读或写`特征值`的请求 ...

  8. layui的单选框

    <script type="text/html" id="radioTpl"> <input type="radio" n ...

  9. layui的时间线当点击按钮的时候自动添加一条新时间线

    $('.littleTaskBtn li').on('click',function(){ var content=$('.content').html(); $('.layui-timeline-i ...

  10. CCNA2.0笔记_IP连接排错

    IPv4 路由排错 ping tracert traceroute telnet show mac address-table show interfaces fastEthernet 0/1 sho ...