Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use javascript to determine whether the coordinates are within the map area

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use javascript to judge whether the coordinates are within the map area". In the daily operation, I believe many people have doubts about how to use javascript to judge whether the coordinates are within the map area. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubts of "how to use javascript to judge whether the coordinates are within the map area". Next, please follow the editor to study!

The specific requirements are as follows:

According to Tencent Map, the distribution area is divided, there are several distribution sub-stations under the main station, and then the receiving address in the order is assigned to different distribution sub-stations.

1. Map area division (Tencent Map)

1.1 、 HTML

Reset the map

1.2 、 JS

/ / initialize the new map initNewMap:function () {var map = new qq.maps.Map ("container"), {center: new qq.maps.LatLng (36.05562103.88191), / / the central geographic coordinates of the map. The central geographic coordinates of the zoom:13// map. }); Var drawingManagerOpt = new qq.maps.drawing.DrawingManager ({drawingMode: qq.maps.drawing.OverlayType.POLYGON, drawingControl: true, drawingControlOptions: {position: qq.maps.ControlPosition.TOP_CENTER DrawingModes: [qq.maps.drawing.OverlayType.POLYGON]}, circleOptions: {fillColor: new qq.maps.Color (255,208,70,0.3), strokeColor: new qq.maps.Color (88, 88, 88, 1) StrokeWeight: 3, clickable: false}}) DrawingManagerOpt.setMap (map); var points = ""; qq.maps.event.addListener (drawingManagerOpt, 'overlaycomplete', function (event) {event.overlay.getPath (). ForEach (function (e) {var lng=e.getLng (); var lat=e.getLat (); points+=lng+ "," + lat+ "-" }); points=points.substring (0, points.length-1); vm.getPeopleDataByPolygon (points);}) }, / / initialize the old map initOldMap:function (value) {var map = new qq.maps.Map ("container"), {center: new qq.maps.LatLng (36.05562103.88191), / / the central geographic coordinates of the map. The central geographic coordinates of the zoom:13// map. }); / / get the old coordinates let data = $("# jqGrid"). JqGrid ('getRowData', getSelectedRow ("# jqGrid")); var areaCoordinateArray = new Array (); areaCoordinateArray = data.areaCoordinate.split ("-"); var path = new Array (); for (var iBoth I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report