Git Product home page Git Product logo

maptalks.js's Introduction

NPM Version Circle CI codecov

A light JavaScript library to create integrated 2D/3D maps.

  • 2D/3D: Integrated 2D/3D maps.
  • Open and pluggable: Easy to extend with techs you may love as plugins.
  • Performant: Can smoothly render tens of thousands of geometries.
  • Simple: Extremely easy to learn and use.
  • Feature Packed: Essential features for most mapping needs.
  • SSR: Server-Side Rendering

The Story

maptalks.js was born for a map-centric project to help YUM! China (the most successful food chain in China) manage and analyze spatial data all over the country for choosing locations of new KFC and PizzaHut restaurants. After verified in many projects of government depts and enterprises, we are glad to open source it, and hoping it can help you deliver better mapping projects.

20220116_213033.mp4

Resources

Supported Enviroments

  • Modern browsers and IE9+ (only IE11 for 3D features)
  • Mobile browsers
  • Node >= 4.x (for Server-Side Rendering)
  • Electron

maptalks is well tested against IE9, IE10, IE11, Firefox and Chrome by more than 1.6K test cases running on CI services.

Install

  • Standalone file

Download the lastest release and load it in your HTML page like:

<link href="path/to/maptalks.css" rel="stylesheet" type="text/css" />
<script src="path/to/maptalks.min.js" type="text/javascript"></script>
  • CDN Just include this in your html:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.css">
<script src="https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.js"></script>
  • NPM
npm install maptalks --save

Plugin Development

It's easy and joyful to write plugins for maptalks, please check out the tutorials and begin to develop your own. And you are welcome to share your work with us.

Contributing

We warmly welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.

Contributing Guide

Please read our contributing guide to learn about our development process, how to propose fixes and improvements, and how to test your changes to maptalks.

Acknowledgments

Maptalks is built on the shoulders of giants. Please refer to ACKNOWLEDGEMENT for details.

maptalks.js's People

Contributors

1dent1ty avatar allanhao avatar axmand avatar axxop avatar blackofmelody avatar brucin avatar charlesleocc avatar cooljser avatar dependabot[bot] avatar deyihu avatar fuzhenn avatar guzhongren avatar hanmag avatar heangfat avatar just-ads avatar lifefriend avatar link-fight avatar liubgithub avatar mirror-riddle avatar mmjinglin163 avatar mrdonkey3 avatar sakitam-fdd avatar shixuan17 avatar signhuwei avatar wordgold avatar wsw0108 avatar wxia5 avatar xiangliliang avatar ydfzgyj avatar yy923683900 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maptalks.js's Issues

zoomBackground对非TileLayer的影响

如DynamicLayer

  • 指定用dom渲染,zoom变化时,DynamicLayer显示和上一个zoom的重叠;
  • 指定用canvas渲染,没有这个问题;

另外,如果在构造map时设置zoomBackground的值为false,则用dom渲染时,不会重叠,但是过渡过程中有明显重叠。

implements SVG+IMG mode for map

Transferred from: #65

地图目前以Canvas实现为主, 但在一些特殊场景下, 例如高分辨率(大屏)时, Canvas无法胜任, 故为map提供SVG+IMG模式.

VectorLayer采用SVG实现, TileLayer采用IMG实现, 除了IE8-用VML外, 和IE8-的实现基本相同.

cartooCSS中支持的样式示例

Transferred from: #19

//图片标注
var icon_img = {

"marker-placement":"point", //point | line | interior

"marker-file"   : "bus.png",
//设定marker-file后, 只有下面的属性起作用
"marker-width"  : 20,
"marker-height" : 20,
"marker-opacity": 1,

//两个cartocss里没有的扩展属性, 用来标注相对中心点的像素距离
"marker-dx"     : 0, //<-------
"marker-dy"     : 0  //<-------

};

//矢量样式, 但优先级比marker-file要低
var icon_vector = {

"marker-placement":"point", //point | line | interior

//marker-type中定义了若干cartoCSS中没有的属性值
"marker-type": "ellipse", //<----- ellipse | arrow | triangle | square等,默认ellipse
"marker-opacity": 1,
"marker-fill": "#ff0000",
"marker-fill-opacity": 1,
"marker-line-color": "#0000ff",
"marker-line-width": 1,
"marker-line-opacity": 1,
"marker-width": 30,
"marker-height": 30,

"marker-dx": 0,
"marker-dy": 0

};

//文字标注的所有属性
var icon_text = {

"text-placement"    : "point", // point | vertex | line | interior

"text-name"         : "文本标注:[marker_name]",
"text-face-name"    : "arial",
"text-size"         : 12,
"text-fill"         : "#550033",
"text-opacity"      : 1,
"text-halo-fill"  : "#fff",
"text-halo-radius": 0,

"text-dx"           : 0,
"text-dy"           : 0,

"text-horizontal-alignment" : "middle", //left | middle | right | auto
"text-vertical-alignment"   : "middle",   // top | middle | bottom | auto
"text-align"                : "left" //left | right | center | auto

};

//线样式
var line = {

"line-pattern-file" : "line-pattern.png",
"line-color"        : "#f00",
"line-width"        : 5,
"line-opacity"      : 1,
"line-join"         : "miter", //round bevel
"line-cap"          : "round", //butt square
"line-dasharray"    : [20, 5, 20]

};

//填充样式
var polygon = {

"polygon-pattern-file"  : "polygon-pattern.png",
"polygon-fill"          : "#f00",
"polygon-opacity"       : 1

};

geometry.fromJSON转化会丢失id属性

如题。
测试的geometry为label,json字符串由label.toJSON()获得
json片段:
feature:{
crs: Object
geometry: Object
id: "NWP_LABEL_0"
properties: Object
type: "Feature"
}
现象,fromJSON后,label中无_id,故无法通过label.getId获取之前设置的id

实现marker的bounce功能

调用的时候, marker会蹦达一下, 调用方法:

marker.bounce({
  'dx' : 0,
  'dy' : 10,
  'duration' : 300
});

鼠标事件containerPoint不正确

测试页面:

<!DOCTYPE>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Maptalks Quick Start</title>
    <script type="text/javascript" src="maptalks.js"></script>
</head>
<body>
<div style="width:800px;height:600px;" id="map"></div>
<script type="text/javascript" src="bundle.js"></script>
</body>
</html>

geometry与map 之间事件冲突

现象:geometry的{'draggable' :true},点击geometry,map的拖动事件就无效了,
只有拖动geometry之后,才能恢复map的drag事件。应该是mousedown的事件冲突了。
也即是当geometry设置 dragable,当用户click geometry但是不进行后续的拖动,即可触发该bug。

说明:该问题出现在events重构之前的代码(重构之后的代码暂测试)

增强Control.Button的事件回调参数

Transferred from: #59

增强Control.Button的事件回调函数的参数
目前click,mousedown等事件回调函数只返回了mouseevent, 改为和map, geometry的事件回调函数统一起来
{
"target": 发起事件的button对象,
"type":"mousedown"/"click"/"touchend",
"domEvent":mouseEvent
}

FeatureQuery,TopoQuery, DynamicLayer等依赖服务的类提取为增强包

Transferred from: #36

考虑将FeatureQuery,TopoQuery, DynamicLayer, map的snap方法等需要调用后台服务的类和方法从引擎核心库中独立出来做成maptalks的增强包.

@MapTalks/talkers

增强包暂名为: maptalks.service.js/maptalks.service.min.js

js文件的命名规则:
product-name.plugin-ver.sion.filetype.js
参考:
http://stackoverflow.com/questions/7273316/what-is-the-javascript-filename-naming-convention

关于animation的一些构想

geometry显示隐藏动画,例如从屏幕上方落下,淡出隐藏。以下伪代码:
animations:[
{
type:'drop',
start_x: screen_width/2,
start_y: 0,
end_x: screen_width/2,
end_y: screen_height/2
}
]

android手机缩放到达minZoom不回弹

android手机里
设置了minzoom之后
当手势触摸缩放层级小于minzoom之后
释放手势地图不会自动回弹到minzoom
需要再点一下地图才会回弹到minzoom层级

类层级调整

Transferred from: #25

类层级调整

maptalks
    .Map
    .Layer
    .Geometry
        .Marker
        .Point
        .Polyline
        .Polygon
        .MultiPoint
        .MultiPolyline
        .MultiPolygon
        .Circle
        .Ellipse
        .Rectangle
        .Sector
        .Vector
    .Control
        .Attribution
        .Nav
        .Scale
        .Zoom
        .Toolbar
        .Panel
        .Button 
        .InfoWindow
        .Label
        .Menu
    .Handler
       .Drag
       .Touch
    .Tool
        .ComputeAreaTool
        .DistanceTool
        .DrawTool
    .Utility
        .GeoUtils
        .SimplifyUtil
        .Util
        .DomUtil
        .Browser
        .Class
        .Event
        .Support
    .Render
        .xxxxx
    .Query
        .RemoteQuery
        .SpatialFilter

增加地址/坐标解析/反解析工具类: GeoCoder类

Transferred from: #8

对主流的GeoCoding服务做一下包装, 能够通过GeoCoder查询地址对应的坐标.

  1. 统一各主流GeoCoding服务的API接口
  2. 用服务的官方API接口调用服务
  3. 参数中指定调用哪个GeoCoding服务.

Label截图在mac os下文字异常

如题:
label以及由label构建的table调用在mac os上部署的截图服务,生成的图片中字符异常,导致
界面布局错乱。如下图:
123

实现动画接口

Transferred from: #76

设计一套简单易用的动画接口, 方便用户实现动画功能.
动画涵盖

  1. 图形的位置改变动画
  2. 图形的形状变化动画
  3. 图形的样式变化动画(例如颜色的渐变)

markerFile的symbol中如果没有设定markerWidth或markerHeight, markerExtent的高宽都是0

例如:

{
   'markerFile' : 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgaGVpZ2h0PSI0NiIgd2lkdGg9IjMyIiB2aWV3Qm94PSIwIDAgMTYgMjMiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiID48ZGVmcz48L2RlZnM+IDxwYXRoICBmaWxsPSIjREUzMzMzIiBzdHJva2UtbGluZWNhcD0iYnV0dCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTggMjNsMCAwIDAgMCAwIDAgMCAwIDAgMGMtNCwtNSAtOCwtMTAgLTgsLTE0IDAsLTUgNCwtOSA4LC05bDAgMCAwIDBjNCwwIDgsNCA4LDkgMCw0IC00LDkgLTgsMTR6IE01LDkgYTMsMyAwLDEsMCwwLC0wLjlaIj48L3BhdGg+IDwvc3ZnPg=='
}

计算出来的markerExtent高宽都是0

label的boxTextAlign功能问题

该功能应该是label中的文字相对label居左、居中、居右。
目前的效果是label的box针对center居左、居中、居右。

svg图片放大后截图变模糊

@brucin

原因:
node中用svg2img转化svg时, 只能按照svg原始大小转化为1:1的png后再放大, 导致模糊.

SVG缩放是解决该问题的关键点, 可参考 https://www.douban.com/note/271260021/

SVG的缩放需要按照比例来设置svg的width/height和viewBox来进行, 这个解析比较复杂且容易出错, 暂时没有找到没有很好的解决方案

实际应用中可以通过调整svg的原始大小来解决模糊问题, 只要把svg图片原始大小尽量做大一点, 就不会模糊了.

label.setTextAlign的调整

Transferred from: #85

label.setTextAlign方法

作用:
调整文字和边框的相对位置

问题:

  1. textAilgn起作用的限定条件比较多,某个条件不满足时textAlign不起作用,使用过程中容易引起困惑。
  2. 计算偏移量是采用boxMinWidth作为参考标准,但boxMinWidth并不是box的实际宽度,可能会在某些情况下位置不准确
  3. symbol中也存在类似的textHorizontalAlignment属性,可以考虑改名为boxTextAlign

调整目标:
让textAlign的作用更加明确更符合直觉

测面工具的修改

Transferred from: #78

面积测算工具的完善, 包括用marker实现各节点等

另面积测算工具需要考虑CRS是否包含面积计算公式.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.