Total Pageviews

Saturday, May 31, 2014

នេះជា Type ShapeObject របស់ Corona SDK (detail2)

 Methods
 (Inherits methods from DisplayObject)
 object:setFillColor()
 ប្រើសំរាប់បញ្ចូលនៅ fill color of vector and text objects ដែលវា applied ទៅនឹង tint to image objects
object:setFillColor( gray )
object:setFillColor( gray, alpha )
object:setFillColor( red, green, blue )
object:setFillColor( red, green, blue, alpha )
object:setFillColor( gradient )

gray, red, green, blue, alpha (optional)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the object.


gradient (optional)

Table. See the gradient fill example below.


Gotchas

In builds based on V1 Graphics, continue using setTextColor() to set the fill color for text objects created via display.newText().


Examples


Vector Object Fill
 local vertices = { 0,-110, 27,-35, 105,-35, 43,16, 65,90, 0,45, -65,90, -43,15, -105,-35, -27,-35 }

local star = display.newPolygon( 300, 300, vertices )
star:setFillColor( 1, 0.2, 0.2 )

Text Object Fill
 local myText = display.newText( "hello", 0, 0, native.systemFontBold, 12 )

myText:setFillColor( 1, 0.2, 0.2 )

Gradient Fill
 local rect = display.newRect( 0, 0, 100, 200 )

local gradient = {
    type="gradient",
    color1={ 1, 1, 1 }, color2={ 0.8, 0.8, 0.8 }, direction="down"
}
rect:setFillColor( gradient )

Image Tint
 local image = display.newImage( "image.png" )
image:setFillColor( 0.72, 0.9, 0.16, 0.78 )  -- Tints image green

object:setStrokeColor()
ប្រើសំរាប់បញ្ចូលនៅ stroke (border) color of vector objects
Syntax:
object:setStrokeColor( gray )
object:setStrokeColor( gray, alpha )
object:setStrokeColor( red, green, blue )
object:setStrokeColor( red, green, blue, alpha )

gray, red, green, blue, alpha (required)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the stroke.


សូមមើលកូដះ
 local rect = display.newRect( 150, 150, 100, 100 )
rect:setFillColor( 1, 1, 0.8 )
rect:setStrokeColor( 1, 0, 0 )
rect.strokeWidth = 8

នេះជា Type ShapeObject របស់ Corona SDK (detail1)

នេះជា Type ShapeObject របស់ Corona SDK
សំរាប់ Vector display objects ដែលជា objects បានបង្កើតឡើងមិនមាន images, ដូចជា rectangles, circles, rounded rectangles and lines
នេះជា Properties របស់វា
object.blendMode
ប្រើសំរាប់ប្តូរនៅ blend mode on a specific object
នេះជា Blend mode types
Standard Presets
Normal: វាជា ស្តងដារ blend mode
Add: វាដូចគ្នានឹង linear dodge, additive blends are useful for glowing effect
Multiply: ប្រើជា multiply blends វាមានប្រយោជន៏សំរាប់ បង្កើត shadows, blending with white results in no change, blending with other colors will darken the composited image
Screen: ប្រើសំរាប់ lighten images ដោយគ្មាន lightening the darkest area

Porter – duff presets
Clear
Src
Dst
srcOver
dstOver
srcAtop
dstAtop
xor

Custom blend modes
សំរាប់ Custom blend modes ប្រើសំរាប់គ្រប់គ្រងនៅ source and destination factors ដែលប្រើនៅក្នុង blending calculation។ វាប្រើតាមរយះ Lua table and destination factors
Key
srcColor(តំរូវការ) វាជា String
scrAlpha(ជំរើស) វាជា String ដែលតំលៃដើមគឺជា srcColor
dstColor(តំរូវការ) វាជា String
dstAlpha(ជំរើស) វាជា String ដែលតំលៃដើមដូចគ្នានឹង dstColor

values
zero
one
srcColor
oneMinusDstColor
srcAlpha
oneMinusSrcAlpha
dstAlpha
oneMinusDstAlpha
srcAlphaSaturate

ដែនកំនត់
សំរាប់ android devices ខ្លះ វាមិនអាច load images ជា premultiplied alpha
សូមមើលកូដះ
Additive blend
local bkgd = display.newImage( "blendmode_bg.jpg" )
local laser = display.newImage( "blendmode_laser2.png" )
laser.blendMode = "add"

object.fill
សំរាប់ object fills, Corona ប្រើ concept of paint។ នៅពេលដែលដាក់វាជា assign a paint to a fill ប្រើសំរាប់ interior area នៃ shape is rendered
Paint types:
សំរាប់ general, paints ជា Lua tables ដែលផ្ទុកនៅ data។ វាមានប្រភេទផ្សេងនៃ paints:
Paint: ជា solid colors
bitmapPaint: ជា texture/images
CompositePaint: ជា multi textures
GradientPaint: ជា linear gradients
ImageSheetPaint: ជា Texture atlases
សូមមើលកូដះ
Local rect = display.newRect (135,100,50,50)
Rect.fill = {1,0,0} – red

object.path
វាជា Paths are a property របស់ shapes ដែលអាចគ្រប់គ្រង់លើ geometry of the shape
សូមមើលកូដះ
local rect = display.newRect( 135, 100, 50, 50 )
local path = rect.path
transition.to( path, { width=200 } )

object.stroke
សំរាប់ object strokes, Corona ប្រើ concept paint
សំរាប់ general, paints ជា Lua tables ដែលផ្ទុកនៅ data។ វាមានប្រភេទផ្សេងនៃ paints:
Paint: ជា solid colors
bitmapPaint: ជា texture/images
CompositePaint: ជា multi textures
GradientPaint: ជា linear gradients
ImageSheetPaint: ជា Texture atlases
សូមមើលកូដះ
local rect = display.newRect( 135, 100, 50, 50 )
rect.stroke = { 1, 0, 0 } -- red
rect.strokeWidth = 4   

object.strokeWidth
ប្រើសំរាប់បញ្ចូលនៅ Stroke width of vector objects នៅក្នុង pixels។ សូមចំណាំថា stroke widths are broken up to inner and outer parts។ វាជា stroke is centered នៅលើ boundaries of the object។ វាប្រើដោយចែកនឹង២ ពេលនោះ math.floot() on values
ចំណាំះ សំរាប់ stroke widths of an object is o by default if not set



នេះជា Type Recording របស់ Corona SDK

នេះជា Type Recording របស់ Corona SDK
សំរាប់ Recording objects ត្រូវបានបង្កើតឡើងដោយប្រើ media.newRecording()

នេះជា Methods របស់វាះ
Methods
(Inherits methods from Userdata)

object:getSampleRate()
ប្រើសំរាប់ទទួលនៅ current audio recording sample rate (ប្រើសំរាប់ record audio)
Syntax: recording:getSampleRate()
សូមមើលកូដះ
R:setSampleRate (rate) – request a new sampling rate
Local actualRate = r:getSameRate()s

object:getTunerFrequency()
ប្រើសំរាប់ត្រឡប់នៅ last calculated frequency in Hz វាធ្វើការតែ tuner was on។ សូមមើល Recording:startTuner()
សំរាប់តំលៃត្រឡប់មកវិញគឺជា currently estimated pitch នៃ audio input, វាបង្ហាញនៅ frequency in Hz តំលៃត្រឡប់គឺ០ បើសិនគ្មាន pitch could be detected
Syntax: recording:getTunerFrequency()
សូមមើលកូដះ
Local r = media.newRecording()
R:startTuner(0
R:startRecording()
Local f = r:getTunerFrequency()

object:getTunerVolume()
ប្រើសំរាប់ត្រឡប់នៅ mean squared normalized sample value នៃ current audio buffer ដែលវាមាន range [-1..1។ វាធ្វើការនៅពេល Tuner បានបើក សូមមើល Recording:startTuner() 
Syntax: Recording:getTunerVolume()
សូមមើលកូដះ
local r = media.newRecording()
r:startTuner()
r:startRecording()
local v = r:getTunerVolume()
local vdb = 10*math.log( v )

object:isRecording()
ប្រើសំរាប់ត្រឡប់នៅ True បើសិនជា audio recording is currently is progress សំរាប់ false if otherwise
Syntax: Recording:isRecording()
សូមមើលកូដះ
local function recButtonPress ( event )
    if r:isRecording () then
        r:stopRecording()
        media.playSound( dataFileName, system.DocumentsDirectory, onCompleteSound )
    else
        r:startRecording()
    end
end


object:setSampleRate()
ប្រើសំរាប់ request an audio recording sample rate។ សំរាប់ recording sample rate default to 44100។ វាមិន support គ្រប់ទាំង all platforms
Valid rates are 8000, 11025, 16000, 22050, 44100។ ដើម្បីប្រើការ tuning feature ជាមួយនឹង sample rate ពេល other than the default។ វាត្រូវហៅ Recording:setSampleRate() មុនពេលការហៅ Recording:startTuner()
Syntax: Recording:setSampleRate ®
R(តំរូវការ) វាជាចំនួនលេខដែល requested sampling rate។ សំរាប់តំលៃ valid rates are 8000, 11025, 16000, 22050, 44100 សំរាប់ different platforms support different rates; ការប្រើ getSampleRate() ក្នុងការ find out the actual sampling rate
សូមមើលកូដះ
R:setSampleRate(rate) – request a new sampling rate
Local actualRate = r:getSampleRate()

object:startRecording()
ចាប់ផ្តើម recording audio
ចំណាំះ សំរាប់ starting an audio recording នឹងឈប់ any audio playbackyou cant record and play audio at the same time
សំរាប់ Android ត្រូវដាក់ permission នៅក្នុង build.settings

settings =
{
    android =
    {
        usesPermissions =
        {
            "android.permission.RECORD_AUDIO",
        },
    },
}

Syntax:  Recording:startRecording()

សូមមើលកូដះ
 local filePath = system.pathForFile( dataFileName, system.DocumentsDirectory )
r = media.newRecording( filePath)
r:startRecording( )


object:startTuner()
ប្រើសំរាប់​ enables audio tuning feature។ សំរាប់ហ្វាំងសិននេះត្រូវហៅមកប្រើមុន Recording:startRecording()
Syntax: Recording:startTuner()

សូមមើលកូដះ
 local r = media.newRecording()
r:startTuner()
r:startRecording()
local f = r:getTunerFrequency()

object:stopRecording()
ប្រើសំរាប់ឈប់ record audio
Syntax: Recording:stopRecording()
សូមមើលកូដះ
R:stopRecording()
Media.playSound ( dataFileName, system.DocumentsDirectory, onCompleteSound)

object:stopTuner()
ប្រើសំរាប់ stops the tuner module
Syntax:
Recording:stopTuner()

សូមមើលកូដះ
local r = media.newRecording()
r:startTuner()
r:startRecording()
local f = r:getTunerFrequency()
r:stopRecording()
r:stopTuner()


នេះជា Type Runtime របស់ Corona SDK

នេះជា Type Runtime របស់ Corona SDK
នៅពេល Runtime class inherits ពី EventListener។ វាជា singleton class meaning there is only one instance accessible តាមរយះ global Runtime
នេះជាហ្វាំងសិនរបស់វា
Runtime:hasEventSource()
ប្រើសំរាប់កំនត់បើសិនជា device is capable ក្នុងការផ្តល់នៅ events ដែលមាន event source ដូចជា accelerometer or gyroscope។ ត្រូវហៅហ្វាំងសិននេះមុន Runtime:addEventListener() function។ សំរាប់ហ្វាំងសិននេះត្រលប់ជា true បើសិនជាមាន event source។ មានន័យថាវាប្រើ Runtime:addEventListener() ក្នុងការ​ handle its events។ វានឹងត្រឡប់ជា false បើសិនជា event source មិនមាន
Syntax: runtime:hasEventSource (eventSourceName)
eventSourceName (តំរូវការ) ​​​​​​​​​​​​​​​​​​​​​​​វាជា String ដែលជាឈ្មោះរបស់ event source ក្នុងការ check for the existence ដូចជា accelerometer or gyroscope
សូមមើលកូដះ
if Runtime:hasEventSource( "gyroscope" ) then
    Runtime:addEventListener( "gyroscope", myListener )

end

នេះជា Type PickerWidget របស់ Corona SDK

នេះជា Type PickerWidget របស់ Corona SDK
សំរាប់ PickerWheel objects ត្រូវបានបង្កើតឡើងដោយការប្រើ widget.newPickerWheel()
នេះជា Methods របស់វា
Object:getValues() ប្រើសំរាប់ត្រឡប់ជា table ជាមួយនឹង currently selected value/index នៃគ្រប់ទាំង column នៅក្នុង picker wheel
Syntax: object:getvalues()
សូមមើលកូដះ
-- Get the table of current values for all columns
-- This can be performed on a button tap, timer execution, or other event
local values = pickerWheel:getValues()
-- Get the value for each column in the wheel (by column index)
local currentMonth = values[1].value
local currentDay = values[2].value
local currentYear = values[3].value
print( currentMonth, currentDay, currentYear )


នេះជា Type ProgressViewWidget របស់ Corona SDK

នេះជា Type ProgressViewWidget របស់ Corona SDK
សំរាប់ ProgressView objects ត្រូវបានបង្កើតឡើងដោយប្រើ widget.newProgressView()
នេះជា Methods របស់វាះ
Methods
(Inherits methods from GroupObject)
object:setProgress()
ប្រើសំរាប់បញ្ចូលនៅ current progress របស់ ProgressView
Syntax: object:setProgress (progress)
Progress(តំរូវការ) វាជាចំនួនលេខដែល progress (percentage) ដែលត្រូវបញ្ចូលទៅកាន់ progress view។ តំលៃនេះត្រូវតែនៅចន្លោះ ០.០ (empty) and 1.0 (100%)
សូមមើលកូដះ
--set the progress to 50%
progressView:setProgress (0.5)

object:getProgress()
ប្រើសំរាប់ត្រឡប់នៅ current progress value របស់ progressView
Syntax: object:getProgress()
សូមមើលកូដះ
Local curretProgress = progressView:getProgress()

object:resizeView()
ប្រើសំរាប់ resizes នៅ Width of a progressView បន្ទាប់ពីការបង្កើត
Syntax: object:resizeView (newWidth)
newWidth (តំរូវការ) វាជាចំនួនលេខដែលជា new width of the progress view
សូមមើលកូដះ
--resize to 200 pixels
progressView:resizeView (200)



Friday, May 30, 2014

Type Map (detail2)


object:nearestAddress()
វាត្រឡប់នៅកន្លែងដែល Address based នៅលើ latitude & longitude ដែលត្រឡប់ជា mapAddress Event។ សំរាប់ហ្វាំងសិននេះតំរូវការនៅ Internet access to work
Syntax: object:nearestAddress (latitude, longitude, resultHandler)
Latitude(តំរូវការ) វាជាចំនួនលេខដែល latitude in degrees of the desired location
Longitude(តំរូវការ) វាជាចំនួនលេខដែល longitude នៅក្នុង degrees នៃ desired location
ចំណាំះ
នៅលើ android ត្រូវដាក់ ​permission នៅក្នុង build.settings
settings =
{
   android =
   {
      usesPermissions =
      {
         "android.permission.INTERNET",
      },
   },
}

សូមមើលកូដះ
 -- Create a native MapView (requires device build)

local myMap = native.newMapView( 0, 0, 300, 220 )
myMap.x = display.contentCenterX
myMap.y = display.contentCenterY

myMap.mapType = "standard"  --other mapType options are "satellite" or "hybrid"

-- Initialize map to a real location, since default location (0,0) is not very interesting
myMap:setCenter( 37.331692, -122.030456 )

local function mapAddressHandler( event )
    -- handle mapAddress event here
    if event.isError then
        print( "mapView Error: " .. event.errorMessage )
    else
        print( "The specified location is in: " .. event.city .. ", " .. event.country )
    end
end

myMap:nearestAddress( 38.898748, -77.037684, mapAddressHandler )

object:removeAllMarkers()
ប្រើសំរាប់លុបគ្រប់ទាំង markers (pins) ចេញពី Map
Syntax: object:removeAllMarkers()
សូមមើលកូដះ
myMap:removeAllMarkers()
object:removeMarker()
ចំណែកមួយនេះវិញវានឹង លុបនៅ specific marker (pin) ចេញពី Map
Syntax: object:removeMarker (markerId)
makerId(តំរូវការ) វាជាចំនួនលេខដែល marker’s identification number
សូមមើលកូដះ
local myMap = native.newMapView( 00300220 )
myMap.x = display.contentCenterX
myMap.y = display.contentCenterY

local options = { title="Displayed Title", subtitle="subtitle text" }
local markerID = myMap:addMarker( 37.331692, -122.030456, options )

--At some later time/event
myMap:removeMarker( markerID )

object:requestLocation()
វាជា replacement សំរាប់ deprecated object:getAddressLocation()។ វានឹងត្រឡប់ជា numerical latitude & longitude values ដែលផ្តល់នៅ location string។ សំរាប់ coordinates នឹងត្រឡប់ជា mapLocation event។ ដែល coordinates អាចប្រើក្នុងការដាក់នៅ Marker on the map, recenter the map ទៅកាន់ desired location ឬក៏បង្ហាញនៅ other functions ដែលប្រើនៅ latitude & longitude pair
សំរាប់ហ្វាំងសិននេះនឹងទទួលនៅ any address or intersection format as input
Syntax: object:requestLocation (location, resultHandler)
Location(តំរូវការ)វាជា String ដែលជា address, intersection or landmark
ចំណាំះ
សំរាប់ហ្វាំងសិននេះតំរូវការនៅ internet access to work, នៅលើ Android ត្រូវការដាក់ Permission នៅក្នុង build.settings
settings =
{
   android =
   {
      usesPermissions =
      {
         "android.permission.INTERNET",
      },
   },
}

សូមមើលកូដះ
 local function mapLocationHandler( event )
    -- handle mapLocation event here
    if event.isError then
        print( "Error: " .. event.errorMessage )
    else
        print( "The specified string is at: " .. event.latitude .. ", " .. event.longitude )
    end
end

myMap:requestLocation( "1900 Embarcadero Road, Palo Alto, CA", mapLocationHandler )

object:setCenter()
ប្រើសំរាប់ moves the displayed map region ទៅកាន់ new location, ដោយការប្រើនៅ new center point ប៉ុន្តែ maintaining the zoom level។ សំរាប់ parameter ចុងក្រោយវាមានជំរើសនៅ Boolean (default false) ដែលកំនត់ថាតើ transition is animated or happens instantly
Syntax: object:setCenter (latitude, longitude [, isAnimated])
Latitude (តំរូវការ)
វាជាចំនួនលេខដែល latitude របស់ map’s center point
Longitude (តំរូវការ) វាជាចំនួនលេខដែលជា longitude របស់ map’s center point
isAnimated (ជំរើស) វាជា Boolean ថាតើ transition is animated (true) or happens instantly (false, the default)
សូមមើលកូដះ
local myMap = native.newMapView( 00, display.contentWidth, display.contentHeight )
myMap:setCenter( 37.331692, -122.030456 )

object:setRegion()
ប្រើសំរាប់ moves the displayed map region ទៅកាន់ new location, ជាមួយនឹង new center point and horizontal/ vertical span distances ដែលមាននៅក្នុង degrees of latitude and longitude។ វានឹង​ implicitly បញ្ចូលទៅ zoom level។ ហ្វាំងសិននេះនឹង sanity check the span settings and will interpolate a consistent zoom level event បើសិនជា latitudeSpan & longitudeSpan ជាមួយនឹង radically different values។ សំរាប់ parameter ចុងក្រោយគឺជាជំរើសនៃ Boolean default false ដែលកំនត់ថាតើ transition is animated or happens instantly
សូមចំណាំថា degrees of latitude & longitude cover large distances on earth  ដូចនេះវាមានការផ្លាស់ប្តូរតិចតួចក្នុងការ translate into big position changes នៅក្នុង map ជាពិសេសនៅចំនុច close zoom levels សូមចំណាំថា most planet’s map locations គឺទទេដែលវានឹងបង្កើតនៅភាពងាយស្រួលដែលធ្វើការជាមួយនឹង ​latitude/longitude values
Syntax: object:setRegion (latitude, longitude, latitudeSpan, longitudeSpan [, isAnimated])
Latitude( តំរូវការ)វាជាចំនួនលេខដែល latitude of the region’s center point
Longtitude(តំរូវការ) វាជាចំនួនលេខដែល longitude of the region’s center point
latitudeSpan (តំរូវការ) វាជាចំនួនលេខដែល region’s latitudinal span in degrees, this implicitly sets the map’s zoom level
longitudeSpan (តំរូវការ) វាជាចំនួនលេខដែល region’s longitudinal span in degress, this implicitly sets the map’s zoom level
isAnimated(ជំរើស)វាជា Boolean ថាតើ animated the map ចេញពី current region ទៅកាន់ new one។ default is false
សូមមើលកូដះ
local myMap = native.newMapView( 00, display.contentWidth, display.contentHeight )
myMap:setCenter( 37.331692, -122.0304560.010.01 )


Type Map (detail1)

នេះជា Type Map របស់ Corona SDK
សំរាប់ Map View អាចឪ្យ Developer integrate នៅ Map View មួយឬច្រើន ទៅក្នុងកម្មវិធី ហើយវាមាន two way communication between map contents & surrounding application, វារួមបញ្ចូលទាំង address or landmark lookup, កាធ្វើចំណាំនៅ Map with pins, & reverse geocoding (converting latitude/longtitude into the closest street address)
នេះជា Properties របស់វា
object.isLocationVisible
វាជា Read-Only Boolean value ដែល indicating ថាតើ user’s current location is visible នៅក្នុង area currently displayed on the map។ វាអាស្រ័យលើតំលៃប្រហាក់ប្រហែល ហើយវាអាចជា True នៅពេលដែលអ្នកប្រើស្ថិតនៅ slightly offscreen។ សំរាប់ Property របស់វាតែងតែជា false បើសិនជា current location is unknown
ចំណាំះ ដើម្បីឪ្យវា access current location នៅលើ Android, សូមបញ្ចូលវាទៅក្នុង permissions នៅក្នុង build.settings file
settings =
{
    android =
    {
        usesPermissions =
        {
            -- Permission to retrieve current location from the GPS.
            "android.permission.ACCESS_FINE_LOCATION",

            -- Permission to retrieve current location from WiFi or cellular service.
            "android.permission.ACCESS_COARSE_LOCATION",
        },
    },
}

សូមមើលកូដះ
local isLocVisible = myMap.isLocationVisible

object.isScrollEnabled
វាជា Boolean ដែលកំណត់ថាតើ អ្នកប្រើអាច Scroll the map by hand។ តំលៃដើមគឺ True, ការបញ្ចូលទៅជា false ក្នុងការការពារអ្នកប្រើ from scrolling the map។ សូមចំណាំថា a map អាច scrolled/panned តាមរយះ ​
Object:setCenter() & object:setRegion() functions, បើសិនជា this property គឺ false។ វាមានអត្ថប្រយោជន៏បើសិនជាចង់ឪ្យ map movement ដែលគ្រប់គ្រង់ដោយកម្មវិធី មិនមែនអ្នកប្រើ
សូមមើលកូដះ
myMap.isScrollEnabled = false
myMap.isZoomEnabled = false

object.isZoomEnabled
វាជា Boolean ដែលកំនត់ថាតើអ្នកប្រើប្រាស់ប្រើ pinch/zoom gestures ទៅកាន់ zoom map។ តំលៃដើមជា false ក្នុងការការពារអ្នកប្រើប្រាស់ចេញពី zooming the map។ សូមចំណាំថា a map can still be zoomed តាមរយះ object:setRegion() function ទោះបីជា Property បានបញ្ចូលទៅជា false
សូមមើលកូដះ
myMap.isScrollEnabled = false
myMap.isZoomEnabled = false

object.mapType
វាជា String ដែលកំណត់នៅ ប្រភេទរបស់ map display។ តំលៃរបស់វាអាចជា standard (default)/ saterllite/ hybrid
សូមមើលកូដះ
Local myMap = native.newMapView (0,0, display.contentWidth, display.contentHeight)
myMap.mapType = “satellite”

Methods
object:addMarker()
ប្រើសំរាប់បន្ថែម pin ទៅកាន់ Map តាមទីតាំងច្បាស់លាស់ណាមួយ។ វានឹងបង្ហាញនៅ title & subtitle ដែលបង្ហាញលើ small popup នៅពេលដែល pin ត្រូវបាន Touched។ ហ្វាំងសិននេះអាចត្រឡប់ជា identification number សំរាប់ marker ដែលបានបន្ថែម ឬក៏ nil បើសិនជា failure។ លេខនេះអាចប្រើជាមួយនឹង object:removeMarker() to remove a marker
Syntax: object:addMarker (latitude, longitude)
Object:addMarker (latitude, longitude, options)
Latitude (តំរូវការ) វាជាចំនួនលេខដែល marker’s latitude in degrees
Longitude (តំរូវការ) វាជាចំនួនលេខដែលជា marker’s longitude in degrees
Options(ជំរើស) វាជាតារាងដែលជា table of options សំរាប់ marker

Options reference
Options.title( ជំរើស) វាជា String ដែលជា Title បង្ហាញលើ pop up ដែលបង្ហាញនៅពេលអ្នកប្រើប្រាស់ taps the marker
Options.subtitle (ជំរើស) វាជា String ដែល subtitle បង្ហាញនៅលើ pop up ដែលបង្ហាញនៅពេលអ្នកប្រើ taps the marker
Options.listener (ជំរើស)
វាជាហ្វាំងសិនដែល ​listener នឹងត្រូវបានហៅនៅពេលដែល marker ត្រូវបាន tapped
Options.imageFile(ជំរើស)
វាជា String ដែលជាឈ្មោះរបស់ image ត្រូវប្រើសំរាប់ markerthe default base director is the resource directory។ វាអាចជា ​table of the form {baseDir =, filename =} វានឹងប្រើនៅ dynamic image selection។ ចំណែក coordinates are returned as a mapMarker


សូមមើលកូដះ
local function markerListener(event)
    print( "type: ", event.type )  --event type
    print( "markerId: ", event.markerId )  --id of the marker that was touched
    print( "lat: ", event.latitude )  --latitude of the marker
    print( "long: ", event.longitude )  --longitude of the marker
end

local myMap = native.newMapView( 0, 0, 300, 220 )
myMap.x = display.contentCenterX
myMap.y = display.contentCenterY

-- This will look in the resources directory for the image file.
local options =
{
    title = "Displayed Title",
    subtitle = "subtitle text",
    listener = markerListener,
    imageFile =  "someImage.png",
}

-- Alternatively, this looks in the specified directory for the image file.
--[[
local options =
{
    title = "Displayed Title",
    subtitle = "subtitle text",
    listener = markerListener,
    imageFile =
    {
        filename = "someImage.png",
        baseDir = system.TemporaryDirectory
    }
}
--]]

local result, errorMessage = myMap:addMarker( 37.331692, -122.030456, options )
if ( result ) then
    print( "everything went well" )
else
    print( errorMessage )
end

object:getAddressLocation() វាត្រូវបានប្រើជំនួសដោយ object:requestLocation()

(Deprecated: Use object:requestLocation() instead.)
object:getUserLocation()
ប្រើសំរាប់ត្រឡប់នៅ table ដែលផ្ទុកនៅតំលៃសំរាប់អ្នកប្រើប្រាស់ current location។ សំរាប់តារាងវាដូចគ្នានឹង GPS location events។ បើសិនជាវាត្រឡប់ជា location.errorCode field មិនត្រូវបាន nil។ ពេលនោះវានឹង indicates ថាតើ application has failed to fetch នៅ user’s current location។ វាអាចកើតឡើងនៅតាមហេតុផលនេះះ
Current location has not been received yet
Current location tracking is not available on the device
The application does not have permission
Syntax: object:getUserLocation()

ចំណាំះ
ដើម្បីទាញយកនៅ current location នៅលើ Android ត្រូវតែដាក់ permissions នៅក្នុង build.settings បើមិនទេហ្វាំងសិននេះនឹងត្រឡប់នៅ location table with the location.errorCode field set and current location marker នឹងមិនបង្ហាញលើ Map ទេ
settings =
{
    android =
    {
        usesPermissions =
        {
            -- Permission to retrieve current location from the GPS.
            "android.permission.ACCESS_FINE_LOCATION",

            -- Permission to retrieve current location from WiFi or cellular service.
            "android.permission.ACCESS_COARSE_LOCATION",
        },
    },
}

សូមមើលកូដះ
 local myMap = native.newMapView( 0, 0, 320, 480 )
myMap.x = display.contentCenterX
myMap.y = display.contentCenterY

local locationTable  = myMap:getUserLocation()
local locationtxt = display.newText( "My location is: ", 0, 0, native.systemFont, 16 )

if ( locationTable.errorCode ) then
    locationtxt.text = locationtxt.text .. locationTable.errorMessage
else
    locationtxt.text = locationtxt.text .. locationTable.latitude .. ", " ..locationTable.longitude
end