This is the first day of my participation in the August More Text challenge

Recently just developed small procedures, there are a lot of do not understand the place, record, in case of need, review the old to know new.

One, the map

Common attributes of map

The property name Attributes that
longitude longitude
latityde latitude
scale Zoom level. The value ranges from 3 to 20
min-scale Minimum zoom level. Default is 3
max-scale Maximum scale level
markers Mark points
polyline route
circles round
include-points The zoom view contains all coordinate points
 <map type="2d" id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}"
        markers="{{markers}}" polyline="{{polyline}}" style="width: 100%; height: 100%" show-location
        show-compass enable-rotate>
    </map>
Copy the code

Second, the marker

A marker on a map

The property name Attributes that
content Bubble text
color Text color
fontSize Text size
borderRadius Border with rounded corners
borderWidth Border color
bgColor The background color
padding Text margin white

Three, polylines,

Specify a series of coordinate points from the first item to the last item in the array. When drawing a rainbow line, specify the colors of different sections. For example, points contain five points, then colorList should pass in four color values. If the length of colorList is less than point.length-1, the color of the remaining sections is the same as that of the last item.

The property name Attributes that
points Latitude and longitude array
color The color of the line
colorList Rainbow line
width Line width
dottedLine Whether the dotted line
arrowLine A line with an arrow
borderColor The border color of the line
borderwidth The thickness of the line
level The hierarchy

The level field represents the hierarchical relationship with other maps, as shown below

The property name Attributes that
aboverLabels On all poIS
abovebuildings Above the block below the POI
aboveroads Road up the stairs under the block

Fourth, the polygon

Form closed polygons according to points

The property name Attributes that
points Latitude and longitude array
strokeWidth Stroke width
strokeColor Stroke color
fillColor Fill color
level The hierarchy

Five, the circle

Form a circle according to latitude, longitude and radius

The property name Attributes that
longitude longitude
latityde latitude
color Stroke color
fillColor Fill color
strokeWidth Stroke width
radius The radius of
level The hierarchy


m a p The attributes of the basic can master, general m a p Will be used in combination with the location, let’s go to have a look! Map attributes can be mastered, generally map and location will be used together, let’s go to have a look!

Six, wx. StartLocationUpdateBackground

Wx. StartLocationUpdateBackground (Object Object), call in the style of Promise, and need to guide the user authorization (scope. UserLocationBackground)

  • Open the small program to enter the front and back to receive messages

Seven, wx. StartLocationUpdate

Call in Promise style, need to guide user authorization (scope.userLocation)

  • Receive location message when entering foreground by opening small program

Eight, wx. OnLocationChange

Call in Promise style

  • Monitor real-time location change events, should be combined with wx. StartLocationUpdateBackground, wx. StartLocationUpdate use.

Nine, wx. GetLocation

Call in Promise style, need to guide user authorization (scope.userLocation)

  • Get the current location, speed, the user leaves the small program, this interface cannot be called.
  • If high-precision positioning is enabled, the interface time increases
  • The coordinate format of the map is GCJ02
  • High-frequency calls consume power and require constant positioning for use wx.onLocationchange

Parameters that

object object

The property name Attributes that
type Wgs84 returns GPS coordinates and GCJ02 returns coordinates that can be used for wx.openLocation. The default is WGS84
altitude True returns height information, which slows down the interface return speed
isHighAccuracy High precision positioning
highAccuracyExpireTime High precision positioning supermarket time (MS) High precision positioning above 3000ms is effective

Object.success callback function

The property name Attributes that
longitude Longitude, range -90 to 90, negative number indicates south latitude
latityde Latitude, range of -180~180, negative numbers indicate west longitude
speed Velocity (m/s)
accuracy Accuracy of position
altitude The width (m)
verticalAccuracy Vertical accuracy (Android not available, return 0)
horizontalAccuracy Level of accuracy
wx.getLocation({
 type: 'gcj02',
 success (res) {
   const latitude = res.latitude
   const longitude = res.longitude
   const speed = res.speed
   const accuracy = res.accuracy
 }
})
Copy the code