Total Pageviews

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 )


No comments:

Post a Comment