<body>
<div id="map">
<div id="menu">
<button id="zoom_in">放大</button>
<button id="zoom_out">缩小</button>
<button id="panto">移动到“武汉”</button>
<button id="restore">复位</button>
</div>
</div>
<script>
var map=new ol.Map({
target:'map',
layer:[],
view:new ol.View({
center:[12950000,4860000],
zoom:8,
minZoom:6,
maxZoom:12,
rotation:Math.PI/6//设置旋转角度
})
})
var tileLayer=new ol.layer.Tile({
source:new ol.source.OSM()
});
map.addLayer(tileLayer);
var view=map.getView();
var zoom=view.getZoom();
var center=view.getCenter();
var rotation=view.getRotation();
document.getElementById("zoom_out").onclick=function(){
var view=map.getView();
var zoom=view.getZoom();
view.setZoom(zoom-1);
}
document.getElementById("zoom_in").onclick=function(){
var view=map.getView();
var zoom=view.getZoom();
view.setZoom(zoom+1);
}
document.getElementById("panto").onclick=function(){
var view=map.getView();
var wh=ol.proj.fromLonLat([114.31667,30.51667]);
view.setCenter(wh);
}
document.getElementById("restore").onclick=function(){
view.setZoom(zoom);
view.setCenter(center);
view.setRotation(rotation);
}
</script>
</body>

												

OpenLayers 3 的地图基本操作的更多相关文章

  1. HTML5 网络拓扑图整合 OpenLayers 实现 GIS 地图应用

    在前面<百度地图.ECharts整合HT for Web网络拓扑图应用>我们有介绍百度地图和 HT for Web 的整合,我们今天来谈谈 OpenLayers 和 HT for Web  ...

  2. HT for Web整合OpenLayers实现GIS地图应用

    HT for Web作为逻辑拓扑图形组件自身没有GIS功能,但可以与各种GIS引擎即其客户端组件进行融合,各取所长实现逻辑拓扑和物理拓扑的无缝融合,本章将具体介绍HT for Web与开发免费的Ope ...

  3. OpenLayers 3 之 地图视图(View)

    OpenLayers 3 之 地图视图(View) 初始化一幅地图,必备的三要素之一视图(view),这个对象主要是控制地图与人的交互,如进行缩放,调节分辨率.地图的旋转等控制.也就是说每个 map对 ...

  4. OpenLayers 3 之 地图控件(control)

    OpenLayers 3 之 地图控件(control) 地图控件(control)是指地图上比例尺,缩略图,拉近拉远的按钮,滚动控制条等控件,默认控件有三个,可以禁用. OpenLayers 3 之 ...

  5. openlayers对接百度地图新方法

    上次给大家提供的openlayers对接百度地图有些问题,是因为没有进行分辨率设置,也没有进行相应的平面坐标转换,获取getURL的方法还是没有变化的 getURL: function (bounds ...

  6. openLayers,常见地图实例

    http://openlayers.org/en/master/examples/epsg-4326.html -- 标尺 http://openlayers.org/en/master/exampl ...

  7. openlayers模仿google地图--地图版权随鹰眼关闭打开而改变位置

    额..题目有点长......今天有个群友问我.想实现google地图地图版权随鹰眼关闭状态改变位置的功能.就是这种<ignore_js_op> 打开鹰眼时  地图版权也随着鹰眼位置改变而改 ...

  8. 使TileCache配合OpenLayers,产生地图瓦块的一些资料(转)

    在tilecache.cfg中配置好被切割地图的参数,比如: [mytestmap]layers=3,5,7,8type=WMSurl=http://localhost/arcgis/services ...

  9. 【01】openLayers 第一个地图

    效果: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...

随机推荐

  1. PRG(Post/Redirect/Get)

    转自:PRG(Post/Redirect/Get) 摘要: Post/Redirect/Get 简称PRG,是一种用来防止表单重复提交数据的一种Web设计模式 Post/Redirect/Get 简称 ...

  2. 【转载】FaceBook - How to add a Privacy Policy to your Apps?

    When you read through the Facebook Platform Policies, you'll notice that every Facebook App that sto ...

  3. html5存储相关 coookie localstorage session storage

    html5存储 coookie  localstorage   session storage

  4. POJ 1704 Georgia and Bob(阶梯博弈+证明)

    POJ 1704 题目链接 关于阶梯博弈有如下定理: 将所有奇数阶梯看作n堆石头,做Nim,将石头从奇数堆移动到偶数堆看作取走石头,同样地,异或值不为0(利己态)时,先手必胜. 定理证明看此博:htt ...

  5. POJ 1042 Gone Fishing#贪心

    (- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<cstring> using namespace std ...

  6. 浙大pat 1062题解

    1061. Dating (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes ...

  7. C# 几个特殊运算符的理解和Nullable<T> 的研究

    可空值类型和?运算符 谈到运算符,大家一定很熟悉,但是对所有的运算符都能掌握吗? 看了下面代码再回答. Nullable<Int32> count = ; ; bool? flag = f ...

  8. 洛谷-火柴棒等式-NOIP2008提高组复赛

    题目描述 Description 给你n根火柴棍,你可以拼出多少个形如“A+B=C”的等式?等式中的A.B.C是用火柴棍拼出的整数(若该数非零,则最高位不能是0).用火柴棍拼数字0-9的拼法如图所示: ...

  9. 2015 Multi-University Training Contest 4

    1001 Olympiad 签到题1. # include <iostream> # include <cstdio> using namespace std; ]={}; b ...

  10. AJAX 创建表格

    <html><head> <meta http-equiv="Content-Type" content="text/html; chars ...