PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 24 → MapAddItinerary / MapDeleteItinerary Developer to iOS Mobile Plataform with Windev Mobile < 20 version
MapAddItinerary / MapDeleteItinerary Developer to iOS Mobile Plataform with Windev Mobile < 20 version
Débuté par adrianoboller, 19 nov. 2014 11:56 - 22 réponses
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 11:56
Procedure WS_CEP_Rota(LOCAL Origem, LOCAL Destino, LOCAL DebugSN)

//Origem ="dr goulin 1699 curitiba PR"
//Destino = "jose lopacinsk 500 curitiba PR"

IF GloDebugSN = "S" THEN
DebugSN = "S"
END



IF Origem <> "" AND Destino = "" THEN
Destino = Origem
END

nVirgula is int = 0

//VARIAIVEIS
nID_Numero is int = 1
nID_Endereco is int = 1
nID_Bairro01 is int = 1
nID_Bairro02 is int = 1
nID_Cidade01 is int = 1
nID_Cidade02 is int = 1
nID_Estado is int = 1
nID_Pais is int = 1
nID_CEP is int = 1
nQTD_ADDRESS_COMPONENT is int = 0

//Limpa variaveis
//Endereço de Origem
GloVoceEnderecoLongo = "ERRO"
GloDestinoEnderecoLongo = "ERRO"
GloVoceLatitude = 0
GloVoceLongitude = 0
GloDestinoLatitude = 0
GloDestinoLongitude = 0

//Norte
GloLatitudeNorte = ""
GloLongitudeNorte = ""

//Sul
GloLatitudeSul = ""
GloLongitudeSul = ""

//Tempo
GloTempoDestino = ""
GloTempoDestinoText = ""
GloTempoTaxi = ""

//Distancia
GloDistanciaDestino = ""
GloDistanciaDestinoText = ""
GloDistanciaTaxi = ""

//Rota
//GloDebugSN, GloVoceEnderecoLongo, GloVoceEndereco, GloDestinoEnderecoLongo, GloDestinoEndereco, GloTempoDestino, GloTempoDestinoText, GloTempoTaxi, GloDistanciaDestino, GloDistanciaDestinoText, GloDistanciaTaxi, GloVoceLatitude, GloVoceLongitude, GloDestinoLatitude, GloDestinoLongitude, GloLatitudeNorte, GloLongitudeNorte, GloLatitudeSul, GloLongitudeSul is string

//Origem
//LocEnderecoOrigem, LocEnderecoCurtoOrigem, LocNumeroOrigem, LocBairro01Origem, LocBairro02Origem, LocCidade01Origem, LocCidade02Origem, LocEstadoOrigem, LocPaisOrigem, LocCepOrigem, LocLatitudeOrigem, LocLongitudeOrigem, LocLatitudeOrigemNorte, LocLongitudeOrigemNorte, LocLatitudeOrigemSul, LocLongitudeOrigemSul is string = ""

//Destino
//LocEnderecoDestino, LocEnderecoCurtoDestino, LocNumeroDestino, LocBairro01Destino, LocBairro02Destino, LocCidade01Destino, LocCidade02Destino, LocEstadoDestino, LocPaisDestino, LocCepDestino, LocLatitudeDestino, LocLongitudeDestino, LocLatitudeDestinoNorte, LocLongitudeDestinoNorte, LocLatitudeDestinoSul, LocLongitudeDestinoSul is string = ""


ok is boolean = False

IF Origem <> "" AND Destino <> ""

ChangeCharset(charsetOccidental) // SEM ACENTO

Origem = Replace(Origem," ","+")

Origem = Capitalize(WS_RemoveAcentos(Origem))

Destino = Replace(Destino," ","+")

Destino = Capitalize( WS_RemoveAcentos(Destino))

//Aceita endereço e lat e long na origem e destino
UrlRota is string = "http://maps.googleapis.com/maps/api/directions/xml?origin="+Origem+"&destination="+Destino+"&sensor=false&mode=driving"

IF DebugSN ="S" THEN
Info("URL Busca Origem Google",UrlRota)
END
ok = HTTPRequest(UrlRota)


//Rota
IF ok = True THEN

XmlResultado is string = WS_Android_IOS_HTTPGetResult()

IF PositionOccurrence(XmlResultado,"<status>OK</status>",firstRank,FromBeginning) > 0 OR PositionOccurrence(XmlResultado,"<status>ok</status>",firstRank,FromBeginning) > 0

XmlResultado = WS_RemoveAcentos(XmlResultado) // retirou caracteres especiais

IF Length(XmlResultado) > 0 THEN

//Point Market
GloRotaEncode = XmlResultado
nInicioPoint is int = PositionOccurrence(XmlResultado,"<copyrights>",firstRank,FromBeginning)
GloRotaEncode = Middle(XmlResultado,nInicioPoint,Length(XmlResultado))
nInicioPoint = PositionOccurrence(XmlResultado,"<points>",firstRank,FromBeginning)
nFinalPoint is int = PositionOccurrence(XmlResultado,"</points>",firstRank,FromBeginning)
GloRotaEncode = Middle(XmlResultado,nInicioPoint,nFinalPoint-nInicioPoint)

//if DebugSN = "S"
Info("POINT",GloRotaEncode)
//end

sXmlResultadoRecorte is string = XmlResultado

//IMPORTANTE LIMPAR O XML

XmlResultado = WS_RemoveCaracteresRota(XmlResultado) // retirou os steps

IF DebugSN ="S" THEN
Info("Retorno XML Busca Origem",XmlResultado)
END
//Corta inicio
//////////////////////////////////////////////////////////////////////////////////////
nInicio is int = PositionOccurrence(XmlResultado,"</step>",lastRank,FromBeginning) + 7
XmlResultado = Middle(XmlResultado,nInicio,Length(XmlResultado))
XmlResultado = "<leg>"+XmlResultado

//Corta fim
nFim is int = PositionOccurrence(XmlResultado,"</leg>",firstRank,FromBeginning) + 5
XmlResultado = Middle(XmlResultado,1,nFim)
//////////////////////////////////////////////////////////////////////////////////////


IF IniOSMode() = True THEN

NoXml is string = XMLExtractString(XmlResultado,"leg")

//Endereço de Origem
GloVoceEnderecoLongo = XMLExtractString(NoXml,"start_address")
GloVoceEnderecoLongo = Capitalize(GloVoceEnderecoLongo)

//Endereço de Destino
GloDestinoEnderecoLongo = XMLExtractString(NoXml,"end_address")
GloDestinoEnderecoLongo = Capitalize(GloDestinoEnderecoLongo)

//Tempo
NoXml1 is string = XMLExtractString(NoXml,"duration")
GloTempoDestino = XMLExtractString(NoXml1,"value")
GloTempoDestinoText = XMLExtractString(NoXml1,"text")
GloTempoTaxi = GloTempoDestino

//Distancia
NoXml1 = XMLExtractString(NoXml,"distance")
GloDistanciaDestino =XMLExtractString(NoXml1,"value")
GloDistanciaDestinoText = XMLExtractString(NoXml1,"text")
GloDistanciaTaxi = GloDistanciaDestino

//Origem
NoXml1 = XMLExtractString(NoXml,"start_location")
IF Val(XMLExtractString(NoXml1,"lat")) < 0
GloVoceLatitude = XMLExtractString(NoXml1,"lat")
GloVoceLongitude = XMLExtractString(NoXml1,"lng")
END

//Destino
NoXml1 = XMLExtractString(NoXml,"end_location")
IF Val(XMLExtractString(NoXml1,"lat")) < 0 THEN
GloDestinoLatitude = XMLExtractString(NoXml1,"lat")
GloDestinoLongitude = XMLExtractString(NoXml1,"lng")
END


ELSE IF InAndroidMode() = True


//XML Leitura
XmlDoc02 is XMLDocument
XmlDoc02 = XMLOpen(XmlResultado,fromString)

//Endereço de Origem
GloVoceEnderecoLongo = XmlDoc02.leg.start_address
GloVoceEnderecoLongo = Capitalize(GloVoceEnderecoLongo)

//Endereço de Destino
GloDestinoEnderecoLongo = XmlDoc02.leg.end_address
GloDestinoEnderecoLongo = Capitalize(GloDestinoEnderecoLongo)

//Tempo
GloTempoDestino = XmlDoc02.leg.duration.value
GloTempoDestinoText = XmlDoc02.leg.duration.text
GloTempoTaxi = GloTempoDestino

//Distancia
GloDistanciaDestino = XmlDoc02.leg.distance.value
GloDistanciaDestinoText = XmlDoc02.leg.distance.text
GloDistanciaTaxi = GloDistanciaDestino

//Origem
IF XmlDoc02.leg.start_location.lat < 0
GloVoceLatitude = XmlDoc02.leg.start_location.lat
GloVoceLongitude = XmlDoc02.leg.start_location.lng
END

//Destino
IF XmlDoc02.leg.end_location.lat < 0 THEN
GloDestinoLatitude = XmlDoc02.leg.end_location.lat
GloDestinoLongitude = XmlDoc02.leg.end_location.lng
END


END

END

ELSE
GloDestinoEndereco = ""
GloDestinoEnderecoLongo = ""

GloTempoDestino = ""
GloDistanciaDestino = ""
END

END


END



IF DebugSN = "S" THEN
Info(GloRotaEncode)
Info("Origem:",GloVoceEnderecoLongo,GloVoceEndereco,"","Destino:",GloDestinoEnderecoLongo,GloDestinoEndereco,"","Tempo: "+GloTempoDestino,"Distancia: "+GloDistanciaDestino,"","Latitude Origem: "+GloVoceLatitude,"Longitute Origem: "+GloVoceLongitude,"","Latitude Destino: "+GloDestinoLatitude,"Longitude Destino: "+GloDestinoLongitude)
END

////Exemplo: Curitiba - Parana =>>> ( - )
IF QtdeOccurrence(GloVoceEnderecoLongo," - ") = 1
GloVoceEndereco = ""
GloVoceNumero = ""
GloVoceEnderecoLongo = "ERRO"
GloVoceLatitude = 0
GloVoceLongitude = 0
END
////Exemplo: Curitiba - Parana =>>> ( - )
IF QtdeOccurrence(GloDestinoEnderecoLongo," - ") = 1
GloDestinoEndereco = ""
GloDestinoNumero = ""
GloDestinoEnderecoLongo = "ERRO"
END
IF DebugSN = "S"
IF GloVoceEnderecoLongo = "ERRO" OR GloDestinoEnderecoLongo = "ERRO"
Info("Endereço inválido")
END
END

RESULT(GloVoceEnderecoLongo)
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 11:58
Procedure WS_Rota_DecodePoints(encoded is string)

//WS_Rota_PlotarPontos("lsczClaqkHFcB")
//WS_Rota_PlotarPontos("tsczCh~pkHUGa@Ka@G[Eq@IuAK")
//WS_Rota_PlotarPontos("vkczCp|pkHM`DM`DI|BIzBC~@E|@E`AE`AOpECl@Ex@CbACl@Cl@IhBGlBGhBIjBIxCCr@EdB")
//WS_Rota_PlotarPontos("rfczCl|rkH|BL|BN")
//encoded ="lsczClaqkHFcBUGcASmAOuAKM`DW~GMzDa@rKo@hQ]~KzF\TuHHoBFeBa@c@eBgB"
//encoded ="znizCzumjH_CYoDi@}AUYCs@Q"

poly is array of LatLng

IF Length(encoded) >= 6 THEN

b, Shift, Tempresult is int = 0
Index, nLen is int = 0
Lat, Lng is real

nLen = Length(encoded)

WHILE (Index < nLen)

LOOP

Index++
b = Asc(encoded[[Index]]) - 63
Tempresult = BinaryOR(Tempresult,bitLeftShift(BinaryAND(b,0x1f),Shift))
Shift = Shift + 5

DO WHILE(b >= 0x20)

dlat is int

IF BinaryAND(Tempresult,1) <> 0 THEN

dlat = BinaryNOT(bitRightShift(Tempresult,1))

ELSE

dlat = bitRightShift(Tempresult,1)

END

Lat += dlat
Shift = 0
Tempresult = 0

LOOP

Index++
b = Asc(encoded[[Index]]) - 63
Tempresult = BinaryOR(Tempresult,bitLeftShift( BinaryAND(b,0x1f),Shift))
Shift += 5;

DO WHILE (b >= 0x20)

Dlng is int

IF BinaryAND(Tempresult, 1) <> 0 THEN

Dlng = BinaryNOT(bitRightShift(Tempresult,1))
ELSE

Dlng = bitRightShift(Tempresult,1)

END

Lng += Dlng;
Shift = 0
Tempresult = 0

point is LatLng
point.Latitude = Lat / 100000
point.Longitude = Lng / 100000
ArrayAdd(poly,point)

END

END

RESULT poly

//-------------------------------------------------------------C#

//arrSplitRuaNumeroArray is array of geoposi
//StringToArray(arrSplitArray[1], arrSplitRuaNumeroArray,",")

//IF ArrayCount(arrSplitRuaNumeroArray) = 1

////private List<LatLng> decodePoly(string encoded)
//{
//List<LatLng> poly = new List<LatLng>();
//int index = 0, len = encoded.Length;
//int lat = 0, lng = 0;
//while (index < len)
//{
//int b, shift = 0, result = 0;
//do
//{ b = encoded[index++] - 63;
//result |= (b & 0x1f) << shift;
//shift += 5;
//} while (b >= 0x20);
//int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
//lat += dlat;
//shift = 0;
//result = 0;
//do
//{
//b = encoded[index++] - 63;
//result |= (b & 0x1f) << shift;
//shift += 5;
//} while (b >= 0x20);
//int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
//lng += dlng;
//LatLng p = new LatLng((double)lat/ 100000, (double)lng / 100000);
//poly.Add(p);
//}
//return poly;
//}
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 11:59
Procedure WS_Rota_DistanciaEntrePontos(x1 is real, x2 is real, y1 is real, y2 is real)

Dist is real = 0

IF x1 <> "" AND x2 <> "" AND y1 <> "" AND y2 <> "" THEN

Dist = Root( Power(x1-x2,2) + Power(y1-y2,2) )

ELSE

Info("Falta parametros para calcular a distancia da reta entre 2 pontos")

END


RESULT (Dist)
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 11:59
Procedure WS_Rota_Pitagoras(pA is real, pB is real, pC is real)

ABC is real = 0

IF pA = "" AND pB <> "" AND pC <> "" THEN

pA = Root(Power(pB,2) + Power(pC,2))

ABC = pA

ELSE IF pA <> "" AND pB = "" AND pC <> "" THEN

pB = Root(Power(pA,2) - Power(pC,2))

ABC = pB

ELSE IF pA <> "" AND pB <> "" AND pC = "" THEN

pC = Root(Power(pA,2) - Power(pB,2))

ABC = pC

END

RESULT(ABC)
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 11:59
Procedure WS_Rota_PlotarPontos(GoogleMapsPoint is string,distancia is int)

//Market_Itinerary
//GoogleMapsPoint ="lsczClaqkHFcBUGcASmAOuAKM`DW~GMzDa@rKo@hQ]~KzF\TuHHoBFeBa@c@eBgB"
//GoogleMapsPoint = "znizCzumjH_CYoDi@}AUYCs@Q"
//GoogleMapsPoint = "lsczClaqkHFcB"
//encoded ="znizCzumjH_CYoDi@}AUYCs@Q"

//goulin
//p1 is geoPosition
//p2 is geoPosition
//p1..Latitude =-25.4189648
//p1..Longitude = -49.2443820
//
//p2..Latitude = -25.4189929
//p2..Longitude = -49.2440539

//sTempstr is string = WS_CEP_Rota("doutor goulin,1661,curitiba,PR ","leonidas Alves cordeiro,285,piraquara,pr","")
//GoogleMapsPoint = GloRotaEncode


ok is boolean = False

IF Length(GoogleMapsPoint) > 6

gloDesenhaItinerario = True //testa itinerario

x is int = 1

//MapDeleteAll(WIN_Taxi62.ControleMapa)

nInicial is int = 0
arryPoints is array of LatLng

pointA is LatLng
pointB is LatLng

arryPoints = WS_Rota_DecodePoints(GoogleMapsPoint)

WHILE( x < ArrayCount(arryPoints))

pointA = arryPoints[x]
pointB = arryPoints[x+1]
nomeMaker++
MarkerPonto..Position.Latitude = pointA.Latitude
MarkerPonto..Position.Longitude = pointA.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+nomeMaker
MarkerPonto..Description = "Itinerary"+nomeMaker
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)

WS_Rota_PlotarXLinhas(pointA,pointB,distancia)

x++

END


MarkerPonto..Position.Latitude = pointB.Latitude
MarkerPonto..Position.Longitude = pointB.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+x
MarkerPonto..Description = "Itinerary"+x
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)

gloDesenhaItinerario = False

IF pointB.Latitude <> "" AND pointB.Longitude <> "" THEN
ok = True
ELSE
ok = False
END

END

RESULT (ok)
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:00
Procedure WS_Rota_PlotarXLinhas(pointA is LatLng , pointB is LatLng, distancia is int)

IF pointA.Latitude <> "" AND pointB.Latitude <> "" AND pointA.Longitude <> "" AND pointB.Longitude <> ""

CountPoints is int

metrosEntrePontos is int = 10

IF distancia>= 20000 THEN
metrosEntrePontos = 50
ELSE IF distancia>= 15000 THEN
metrosEntrePontos = 40
ELSE IF distancia>= 10000 THEN
metrosEntrePontos = 30
ELSE IF distancia>= 5000 THEN
metrosEntrePontos = 20
END



//
c1 is real = pointA.Latitude - pointB.Latitude
c2 is real = pointA.Longitude - pointB.Longitude


CountPoints = Root(Power(c1,2) + Power(c2,2)) * (metrosDistancia / metrosEntrePontos)

IF CountPoints = 1 THEN CountPoints = 2
IF CountPoints > 0 THEN

c1 = c1 / CountPoints
c2 = c2 / CountPoints

END

WHILE (CountPoints > 1)

CountPoints--
pointA.Latitude -= c1
pointA.Longitude -= c2
nomeMaker++

//plota no mapa
MarkerPonto..Position.Latitude = pointA.Latitude
MarkerPonto..Position.Longitude = pointA.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+ nomeMaker
MarkerPonto..Description = "Itinerary"+ nomeMaker
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)

//IF InAndroidMode() = True
//Multitask(1)
//ELSE IF IniOSMode() = True
//Multitask(-1)
//END

END

END
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:06
Procedure WS_ExtrairEndereco(endereco)

IF GloDebugSN = "S" THEN
NextTitle("Extrair Endereço")
Info("WS_ExtrairEndereco",endereco)
END

sRua, sNumero, sBairro, sCidade, sEstado, sPais, sCep is string = ""

IF endereco <> ""

endereco = Replace(endereco,"State Of ", "",IgnoreCase)

//Separador - das 3 colunas
arrSplitArray is array of strings
StringToArray(endereco, arrSplitArray," - ")
//FOR EACH string sExtracColunn, nRank of endereco SEPAREE by " - "
//
//add(arrSplitArray, sExtracColunn)
//
//END

IF ArrayCount(arrSplitArray) = 3

//Separador , da rua e numero
arrSplitRuaNumeroArray is array of strings
StringToArray(arrSplitArray[1], arrSplitRuaNumeroArray,",")


IF ArrayCount(arrSplitRuaNumeroArray) = 1

sRua = arrSplitRuaNumeroArray[1];

sNumero = "0";

ELSE IF ArrayCount(arrSplitRuaNumeroArray) = 2

sRua = arrSplitRuaNumeroArray[1];

IF PositionOccurrence(arrSplitRuaNumeroArray[2],"-",firstRank) > 0 THEN

arrSplitNumeroArray is array of strings
StringToArray(arrSplitRuaNumeroArray[2], arrSplitNumeroArray,"-")

WHEN EXCEPTION IN
Media is int = (Val(arrSplitNumeroArray[1]) + Val(arrSplitNumeroArray[2])) / 2
DO
sNumero = 0
ELSE
sNumero = Media
END


ELSE

sNumero = arrSplitRuaNumeroArray[2];

END

END


/////
//Separador , do bairro e cidade
arrSplitBairroCidadeArray is array of strings
StringToArray(arrSplitArray[2], arrSplitBairroCidadeArray,",")

IF ArrayCount(arrSplitBairroCidadeArray) = 2

sBairro =arrSplitBairroCidadeArray[1];
sCidade = arrSplitBairroCidadeArray[2];

ELSE IF (ArrayCount(arrSplitBairroCidadeArray) = 3)

sBairro = arrSplitBairroCidadeArray[1];
sCidade = arrSplitBairroCidadeArray[3];

ELSE

sBairro = "";
sCidade = "";

END

//Separador , do bairro e cidade
arrSplitEstadoCepPaisArray is array of strings
StringToArray(arrSplitArray[3], arrSplitEstadoCepPaisArray,",")

IF ArrayCount(arrSplitEstadoCepPaisArray) = 2

sEstado = arrSplitEstadoCepPaisArray[1];
sPais = arrSplitEstadoCepPaisArray[2];
sCep = ""

ELSE IF ArrayCount(arrSplitEstadoCepPaisArray)= 3

sEstado = arrSplitEstadoCepPaisArray[1];
sCep = arrSplitEstadoCepPaisArray[2];
sPais = arrSplitEstadoCepPaisArray[3];
ELSE

sEstado = ""
sCep = ""
sPais = ""

END
ELSE IF ArrayCount(arrSplitArray) = 2

arrSplitRuaCidadeArray is array of strings
StringToArray(arrSplitArray[1], arrSplitRuaCidadeArray,",")

sNumero = "0";
IF ArrayCount(arrSplitRuaCidadeArray) = 1

sRua = arrSplitRuaCidadeArray[1];



ELSE IF ArrayCount(arrSplitRuaCidadeArray) = 2

sRua = arrSplitRuaCidadeArray[1];
sCidade = arrSplitRuaCidadeArray[2];

ELSE IF ArrayCount(arrSplitRuaCidadeArray) = 3

sRua = arrSplitRuaCidadeArray[1];
//--
IF PositionOccurrence(arrSplitRuaCidadeArray[2],"-",firstRank) > 0 THEN

arrSplitNumeroArray is array of strings
StringToArray(arrSplitRuaCidadeArray[2], arrSplitNumeroArray,"-")

WHEN EXCEPTION IN
Media is int = (Val(arrSplitNumeroArray[1]) + Val(arrSplitNumeroArray[2])) / 2
DO
sNumero = 0
ELSE
sNumero = Media
END


ELSE

sNumero = arrSplitRuaCidadeArray[2];

END



//--
sCidade = arrSplitRuaCidadeArray[3];
END


arrSplitEstadoCepPaisArray is array of strings
StringToArray(arrSplitArray[2], arrSplitEstadoCepPaisArray,",")
IF ArrayCount(arrSplitEstadoCepPaisArray) = 2

sEstado = arrSplitEstadoCepPaisArray[1];
sPais = arrSplitEstadoCepPaisArray[2];
sCep = ""

ELSE IF ArrayCount(arrSplitEstadoCepPaisArray)= 3

sEstado = arrSplitEstadoCepPaisArray[1];
sCep = arrSplitEstadoCepPaisArray[2];
sPais = arrSplitEstadoCepPaisArray[3];
ELSE

sEstado = ""
sCep = ""
sPais = ""

END






END

//Replace Estado
sEstado = Capitalize(Clip(sEstado))
IF sEstado <> ""

IF sEstado = "Acre" THEN
sEstado = "AC"
ELSE IF sEstado = "Alagoas" THEN
sEstado = "AL"
ELSE IF sEstado = "Amazonas" THEN
sEstado = "AM"
ELSE IF sEstado = "Amapa" THEN
sEstado = "AP"
ELSE IF sEstado = "Bahia" THEN
sEstado = "BA"
ELSE IF sEstado = "Ceara" THEN
sEstado = "CE"
ELSE IF sEstado = "Distrito Federal" THEN
sEstado = "DF"
ELSE IF sEstado = "Espirito Santo" THEN
sEstado = "ES"
ELSE IF sEstado = "Goias" THEN
sEstado = "GO"
ELSE IF sEstado = "Maranhao" THEN
sEstado = "MA"
ELSE IF sEstado = "Minas Gerais" THEN
sEstado = "MG"
ELSE IF sEstado = "Mato Grosso do Sul" THEN
sEstado = "MS"
ELSE IF sEstado = "Mato Grosso" THEN
sEstado = "MT"
ELSE IF sEstado = "Parana" THEN
sEstado = "PR"
ELSE IF sEstado = "Para" THEN
sEstado = "PA"
ELSE IF sEstado = "Paraiba" THEN
sEstado = "PB"
ELSE IF sEstado = "Pernambuco" THEN
sEstado = "PE"
ELSE IF sEstado = "Piaui" THEN
sEstado = "PI"
ELSE IF sEstado = "Rio de Janeiro" THEN
sEstado = "RJ"
ELSE IF sEstado = "Rio Grande DO Norte" THEN
sEstado = "RN"
ELSE IF sEstado = "Rondonia" THEN
sEstado = "RO"
ELSE IF sEstado = "Roraima" THEN
sEstado = "RR"
ELSE IF sEstado = "Rio Grande DO Sul" THEN
sEstado = "RS"
ELSE IF sEstado = "Santa Catarina" THEN
sEstado = "SC"
ELSE IF sEstado = "Sergipe" THEN
sEstado = "SE"
ELSE IF sEstado = "Sao Paulo" THEN
sEstado = "SP"
ELSE IF sEstado = "Tocantins" THEN
sEstado = "TO"
END

END

END
arrResult is array of strings

Add(arrResult, Capitalize(Clip(sRua)))
Add(arrResult, Clip(sNumero))
Add(arrResult, Capitalize(Clip(sBairro)))
Add(arrResult, Capitalize(Clip(sCidade)))
Add(arrResult, Upper(Clip(sEstado)))
Add(arrResult, Clip(sCep))
Add(arrResult, Capitalize(Clip(sPais)))

IF GloDebugSN = "S" THEN
NextTitle("Extrair Endereço")
Info(arrResult[1],arrResult[2],arrResult[3],arrResult[4],arrResult[5],arrResult[6],arrResult[7])
END

RESULT arrResult
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:07
Procedure WS_CEP_EnderecoDasCoordenadas(LOCAL pLatitude is string, LOCAL pLongitude is string, LOCAL DebugSN)

IF GloDebugSN = "S" THEN
Info("WS_CEP_EnderecoDasCoordenadas")
DebugSN = "S"
END
//pLatitude= "-25.431637"
//plongitude ="-49.203203"
NextTitle("Atenção")

ok is boolean = False
GloEnderecoOK = False

Endereco, RetJson is string = ""
IF pLatitude <> 0 AND pLongitude <> 0 AND pLatitude <> Null AND pLongitude <> Null THEN

Url is string = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"

IF DebugSN = "S"
Info("01",Url)
END

HTTPTimeOut(GloHTTPTimeOut)


ok = HTTPRequest(Url)

IF ok = True THEN

ChangeCharset(charsetOccidental) // SEM ACENTO


RetJson = WS_Android_IOS_HTTPGetResult()//HTTPGetResult(httpResult)
IF Length(RetJson) = 0 THEN

ok= False
ELSE



IF DebugSN = "S"
Info(Url,RetJson)
END

///// teste
//TagEndac is string
//io is int = PositionOccurrence(RetJson, TagEndac, firstRank, IgnoreCase )// + Length(TagEndac)
//
//
//TagEndac = Middle(retjson,PositionOccurrence(RetJson,"""address_components"" :", firstRank, IgnoreCase ),Length(RetJson))
//blocoJson is string = Middle( tagEndac,1,PositionOccurrence(TagEndac,"],", firstRank, IgnoreCase ))
////<Result> = ExtractString(<Initial String> , <Rank> [, <Separator> [, <Browse Direction>]])
//
// if (blocoJson<> "") THEN
//Endereco = ExtractString(blocoJson,firstRank,"""types"" : [ ""street_number"" ]",FromEnd)
//END
//
////Pega endereço (entre duas aspas)
//IF io> 0 THEN
//Endereco = ExtractString(RetJson[[io TO]],4,"""")
//GloEnderecoOK = True
//
//END
////teste
//


TagEnd is string = """formatted_address"" :"
i is int = PositionOccurrence(RetJson, TagEnd, firstRank, IgnoreCase ) + Length(TagEnd)
Endereco =""
//Pega endereço (entre duas aspas)
IF i> 0 THEN
Endereco = ExtractString(RetJson[[i TO]],2,"""")
GloEnderecoOK = True

END

IF Endereco = "" OR RetJson = "ERRO" THEN
// busca por XML
GloEnderecoOK = False
Url = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"

IF DebugSN = "S"
Info("02",Url)
END

HTTPTimeOut(GloHTTPTimeOut)

ok = HTTPRequest(Url)
IF ok = True THEN

RetXml is string = WS_Android_IOS_HTTPGetResult()// HTTPGetResult(httpResult)

IF Length(RetXml) = 0 THEN

ok= False
ELSE

IF DebugSN = "S"
Info("Xml:",RetXml)
END

//<formatted_address>Rua Professora Antonia Reginato Vianna, 442 - Capão da Imbuia, Cajuru, Curitiba - PR, 82810-300, Brasil</formatted_address>

IF PositionOccurrence(RetXml,"<formatted_address>",firstRank) > 0 THEN

//Endereço
nPosicaoInicial is int = PositionOccurrence(RetXml,"<formatted_address>",firstRank) + Length("<formatted_address>")
nPosicaoFinal is int = PositionOccurrence(RetXml,"</formatted_address>",firstRank) + Length("</formatted_address>")
nPosicaoFinal = nPosicaoFinal - nPosicaoInicial
Endereco = Middle(RetXml,nPosicaoInicial,nPosicaoFinal)
GloEnderecoOK = True

END
END
END
END
END
END

IF ok = False THEN
Popup(GloMsgSemInternet,"L")
END



Endereco = WS_RemoveAcentos(Endereco)

END





RESULT (Endereco)
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:09
<?xml version="1.0" encoding="UTF-8"?>
<DirectionsResponse>
<status>OK</status>
<route>
<summary>Av. Victor Ferreira do Amaral</summary>
<leg>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4189503</lat>
<lng>-49.2445516</lng>
</start_location>
<end_location>
<lat>-25.4189929</lat>
<lng>-49.2440539</lng>
</end_location>
<polyline>
<points>lsczClaqkHFcB</points>
</polyline>
<duration>
<value>6</value>
<text>1 min</text>
</duration>
<html_instructions>Siga na direção <b>leste</b> na <b>R. Dr. Goulin</b> em direção à <b>Rua Flávio Dallegrave</b></html_instructions>
<distance>
<value>50</value>
<text>50 m</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4189929</lat>
<lng>-49.2440539</lng>
</start_location>
<end_location>
<lat>-25.4177243</lat>
<lng>-49.2437741</lng>
</end_location>
<polyline>
<points>tsczCh~pkHUGa@Ka@G[Eq@IuAK</points>
</polyline>
<duration>
<value>38</value>
<text>1 min</text>
</duration>
<html_instructions>Vire à <b>esquerda</b> na <b>Rua Flávio Dallegrave</b></html_instructions>
<distance>
<value>144</value>
<text>0,1 km</text>
</distance>
<maneuver>turn-left</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4177243</lat>
<lng>-49.2437741</lng>
</start_location>
<end_location>
<lat>-25.4179433</lat>
<lng>-49.2411403</lng>
</end_location>
<polyline>
<points>vkczCp|pkHD_@Bu@@S@U@e@@K@o@@UDy@@a@HsB@a@@c@</points>
</polyline>
<duration>
<value>38</value>
<text>1 min</text>
</duration>
<html_instructions>Pegue a 1ª <b>à direita</b> para <b>R. Augusto Stresser</b></html_instructions>
<distance>
<value>266</value>
<text>0,3 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4179433</lat>
<lng>-49.2411403</lng>
</start_location>
<end_location>
<lat>-25.4280589</lat>
<lng>-49.2415964</lng>
</end_location>
<polyline>
<points>bmczCblpkHnAq@RKb@UHEr@_@jAm@`Ag@`@QPIf@QJEHAJAHAPA^@NBPD@@b@VvCrBZX`D|Bf@^ZV`Av@TNvA|@h@VVJXHXDfANV@T?T?VCTC`@Eb@IfAQfAS^M|Bm@ZKb@SXK@AJENIj@U</points>
</polyline>
<duration>
<value>91</value>
<text>2 minutos</text>
</duration>
<html_instructions>Vire à <b>direita</b> na <b>Av. Nossa Senhora da Luz</b></html_instructions>
<distance>
<value>1259</value>
<text>1,3 km</text>
</distance>
<maneuver>turn-right</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4280589</lat>
<lng>-49.2415964</lng>
</start_location>
<end_location>
<lat>-25.4282871</lat>
<lng>-49.2414666</lng>
</end_location>
<polyline>
<points>jlezC~npkHl@Y</points>
</polyline>
<duration>
<value>2</value>
<text>1 min</text>
</duration>
<html_instructions>Continue para <b>Av. Mal. Humberto de Alencar Castelo Branco</b></html_instructions>
<distance>
<value>29</value>
<text>29 m</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4282871</lat>
<lng>-49.2414666</lng>
</start_location>
<end_location>
<lat>-25.4276407</lat>
<lng>-49.2405798</lng>
</end_location>
<polyline>
<points>xmezCdnpkHJSBGBG@C@E?C?A?C?CAECCWGWEKCKEIGIEACEEGGGGGKKOKO</points>
</polyline>
<duration>
<value>20</value>
<text>1 min</text>
</duration>
<html_instructions>Curva acentuada à <b>esquerda</b> na rampa de acesso a <b>R. Papa Rafael</b></html_instructions>
<distance>
<value>142</value>
<text>0,1 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4276407</lat>
<lng>-49.2405798</lng>
</start_location>
<end_location>
<lat>-25.4273992</lat>
<lng>-49.2394639</lng>
</end_location>
<polyline>
<points>viezCrhpkHEIEKMg@I_@G]CSAQ?Y@c@</points>
</polyline>
<duration>
<value>8</value>
<text>1 min</text>
</duration>
<html_instructions>Continue para <b>R. Papa Rafael</b></html_instructions>
<distance>
<value>117</value>
<text>0,1 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4273992</lat>
<lng>-49.2394639</lng>
</start_location>
<end_location>
<lat>-25.4300114</lat>
<lng>-49.2153913</lng>
</end_location>
<polyline>
<points>fhezCrapkHNsCJqC?KZ_GF_AN}CP_DN}CHiABo@Da@@MZyE@[VyDH_BJ_BFoAFkADkA@_@BY@[NcCFiADo@Do@ZaHR}DV{DBc@TcEFwAFqBBq@Do@Bi@B_@f@uJP_DJkBHeBNoCNgC</points>
</polyline>
<duration>
<value>155</value>
<text>3 minutos</text>
</duration>
<html_instructions>Continue para <b>Av. Victor Ferreira do Amaral</b></html_instructions>
<distance>
<value>2435</value>
<text>2,4 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4300114</lat>
<lng>-49.2153913</lng>
</start_location>
<end_location>
<lat>-25.4363978</lat>
<lng>-49.2186964</lng>
</end_location>
<polyline>
<points>pxezCdkkkHlBp@`A\hA`@hAd@`@P^N`A`@h@Rl@Vn@Xp@Xr@Zn@Xn@Xp@Zn@XbBt@`Bt@l@Xl@Zp@Vp@X</points>
</polyline>
<duration>
<value>67</value>
<text>1 min</text>
</duration>
<html_instructions>Vire à <b>direita</b> na <b>R. Prof. Nivaldo Braga</b></html_instructions>
<distance>
<value>784</value>
<text>0,8 km</text>
</distance>
<maneuver>turn-right</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-25.4363978</lat>
<lng>-49.2186964</lng>
</start_location>
<end_location>
<lat>-25.4404691</lat>
<lng>-49.2094845</lng>
</end_location>
<polyline>
<points>n`gzCz_lkHdAaDbAaDd@mAd@mA`@sAb@sA`@mA`@mAd@oAd@oAjCcIfAaDfAaDdAaD^eA</points>
</polyline>
<duration>
<value>177</value>
<text>3 minutos</text>
</duration>
<html_instructions>Vire à <b>esquerda</b> na <b>R. Clávio Molinari</b><div style="font-size:0.9em">O destino estará à esquerda</div></html_instructions>
<distance>
<value>1030</value>
<text>1,0 km</text>
</distance>
<maneuver>turn-left</maneuver>
</step>
<duration>
<value>602</value>
<text>10 minutos</text>
</duration>
<distance>
<value>6256</value>
<text>6,3 km</text>
</distance>
<start_location>
<lat>-25.4189503</lat>
<lng>-49.2445516</lng>
</start_location>
<end_location>
<lat>-25.4404691</lat>
<lng>-49.2094845</lng>
</end_location>
<start_address>Rua Doutor Goulin, 1661 - Alto da Glória, Matriz, Curitiba - PR, 80040-280, República Federativa do Brasil</start_address>
<end_address>Rua Clávio Molinari, 1029 - Capão da Imbuia, Cajuru, Curitiba - PR, 82810-210, República Federativa do Brasil</end_address>
</leg>
<copyrights>Dados cartográficos ©2014 Google</copyrights>
<overview_polyline>
<points>lsczClaqkHFcBUGcASmAOuAKD_@DiAB{@JkCN{EpCyAbFgCx@[TGTCp@?`@Hd@X|JjH|AnAlBlA`Ab@r@N~APj@?rBWnCe@|C{@zAm@tB_ATg@@OAI[Kc@IUMYWg@s@KUWgAKq@Ak@\uIdA}Rb@yHv@}Lr@}Nb@mHn@_NZ_F\{GJcDLyBnAgV^wGnDnArCfA`A`@hEfBlNjGzAt@bBp@hCcIjA{ChCcIjA_DrEeNlDiK</points>
</overview_polyline>
<bounds>
<southwest>
<lat>-25.4404691</lat>
<lng>-49.2445516</lng>
</southwest>
<northeast>
<lat>-25.4177243</lat>
<lng>-49.2094845</lng>
</northeast>
</bounds>
</route>
</DirectionsResponse>
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:11
//Point Decodificado

<overview_polyline>
<points>lsczClaqkHFcBUGcASmAOuAKD_@DiAB{@JkCN{EpCyAbFgCx@[TGTCp@?`@Hd@X|JjH|AnAlBlA`Ab@r@N~APj@?rBWnCe@|C{@zAm@tB_ATg@@OAI[Kc@IUMYWg@s@KUWgAKq@Ak@\uIdA}Rb@yHv@}Lr@}Nb@mHn@_NZ_F\{GJcDLyBnAgV^wGnDnArCfA`A`@hEfBlNjGzAt@bBp@hCcIjA{ChCcIjA_DrEeNlDiK</points>
</overview_polyline>
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:14
MapAddItinerary
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:15


Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:17


Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 19 novembre 2014 - 12:20
OBS.:

The image above was blue point plotted in the loop market, since the polyline function has not been done yet in Windev Mobile.
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 22 novembre 2014 - 15:47
Procedure WS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult is string

// Retrieves the result of the query
bufResHTTP = HTTPGetResult(httpResult)

// Result in UTF8 em iOS Apple
IF IniOSMode() = True OR IniOSSimulatorMode() = True OR IniOSEmulatorMode() = True
IF StringCount(bufResHTTP, “ISO-8859-1, IgnoreCase) = 0 THEN
sHTTPResult = UTF8ToString(bufResHTTP)
ELSE
sHTTPResult = AnsiToUnicode(bufResHTTP)
END
ELSE IF InAndroidMode() = True OR InAndroidSimulatorMode() = True OR InAndroidEmulatorMode() = True
// Result in Android
sHTTPResult = bufResHTTP
END

RESULT sHTTPResult
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 22 novembre 2014 - 15:47
Procedure WS_Android_iOs_ReadXml(XML_Retorno is string, Xml_Atributo is string )

//Exemplo de Uso:
// XML_Retorno is string = [
//<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
//xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
//xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
//<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
//xmlns:NS1="urn:act297_RtPlusSSDM-IRtPlusSSDM">
//<NS1:VerificarVersaoDeTabelasResponse xmlns:NS2="urn:act297_RtPlusSSDM">
//<NS2:TVersaoTabelas id="1" xsi:type="NS2:TVersaoTabelas">
//<datHoraMotivos xsi:type="xsd:string">2013-07-11T17:15:33</datHoraMotivos>
//<qtdMotivos xsi:type="xsd:int">3</qtdMotivos>
//<datHoraCartoes xsi:type="xsd:string">2013-07-01T12:00:00</datHoraCartoes>
//<qtdCartoes xsi:type="xsd:int">6</qtdCartoes>
//<datHoraPesquisa xsi:type="xsd:string">2013-07-10T12:14:42</datHoraPesquisa>
//<qtdPesquisa xsi:type="xsd:int">4</qtdPesquisa>
//</NS2:TVersaoTabelas>
//<return href="#1"/>
//</NS1:VerificarVersaoDeTabelasResponse>
//</SOAP-ENV:Body>
//</SOAP-ENV:Envelope>
// ]
//
// Uso da Funcao:
//arrTemp is array of strings = WS_Android_iOs_ReadXml(XML_Retorno,"NS2:TVersaoTabelas")

arrXml_TagResult is array of strings
xposicaoinicial is int = 0
Xposicaofinal is int = 0
X is int = 0
arrXml_Tag is array of strings

Inicial is int = PositionOccurrence(XML_Retorno,"<"+Xml_Atributo,firstRank,FromBeginning)
Final is int = PositionOccurrence(XML_Retorno,"</"+Xml_Atributo+">",lastRank,FromEnd) +Length("</"+Xml_Atributo+">")
XML_Retorno = Middle(XML_Retorno,Inicial,Final - Inicial)
XML_Retorno = Replace(XML_Retorno,Xml_Atributo,"NoXml")
XML_Retorno = "<Xml><Recorte>"+XML_Retorno+"</Recorte></Xml>"

nTotalxml is int = Length(XML_Retorno)

LOOP (nTotalxml)

X++
IFxposicaoinicial = 0 AND Xposicaofinal = 0 AND XML_Retorno[[X]] = "<" THEN
X++
IF XML_Retorno[[X]] = "/" THEN
xposicaoinicial = X + 1
END
END
IF xposicaoinicial > 0 AND XML_Retorno[[X]] = ">" THEN
Xposicaofinal = X
END
IF Xposicaofinal > 0 AND xposicaoinicial > 0 THEN
stag is string = Middle(XML_Retorno,xposicaoinicial,Xposicaofinal - xposicaoinicial)
IF stag="NoXml" THEN
BREAK
END
Add(arrXml_Tag, stag)
Xposicaofinal = 0
xposicaoinicial = 0
END

END

//iOS - Apple (iPhone / iPad / iPod)
IF IniOSMode() = True THEN

NoXml is string
i is int = 1
NoXml = XMLExtractString(XML_Retorno,"NoXml",i)

FOR EACH stag OF arrXml_Tag

temp is string = XMLExtractString(NoXml,stag)
Add(arrXml_TagResult, temp )

END

//Android
ELSE IF InAndroidMode() = True

XmlDoc is XMLDocument
XmlDoc = XMLOpen(XML_Retorno, fromString)
NoXml is xmlNode

FOR EACH NoXml OF XmlDoc.Xml.Recorte on NoXml

FOR EACH sTag OF arrXml_Tag

Add(arrXml_TagResult,NoXml..ChildNode[sTag])

END

END

END

RESULT arrXml_TagResult
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 20 juillet 2016 - 18:44
Prezados,

Como colocar eventos no controle de mapa no mobile:





:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:05
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>

void IOS(){}

//////////////////////////////////////////////////
// Classes
//////////////////////////////////////////////////
#define FONT_SIZE 14
#define LEFT_RIGHT_PADDING 14
#define TOP_BOTTOM_PADDING 10
#define BOTTOM_MARGIN 200

#define BACKGROUND_COLOR darkGrayColor
#define FADE_IN_DURATION 0.4
#define FADE_OUT_DURATION 0.3
#define DELAY 2
#define MAX_CHAR_LINHA 30
#define MAX_LENGTH_LABEL 300
#define LEFT_RIGTH_BORDER_INTERN 10
#define LEFT_RIGTH_BORDER_EXTERN 20
#define TOP_BOTTOM_BORDER_INTERN 10

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define iOS7_0 @"7.0"


// Toast
@interface WDToast : NSObject
// Message
@Property (nonatomic, strong) NSString *Message;
// Durée
@Property (nonatomic) int Delai;
// Champ libellé
@Property (nonatomic, strong) UILabel *label;
+ (WDToast *)toastWithMessage:(NSString *)msg delay:(int)nDelai;
// Affiche le toast
- (void)showOnView:(UIView *)mainView;
@END

// Implémentation de l'interface WDToast
@implementation WDToast
{
CGRect rect;
}

+ (WDToast *)toastWithMessage:(NSString *)msg delay:(int)nDelai;
{
WDToast *t = [[[WDToast alloc] init] autorelease];
t.message = msg;
t.Delai = nDelai;

//Resolucao
float xLabel = 0;
float yLabel = 0;
float wScreen = 0;
float hScreen = 0;
float hLablel = 0;
float wLabel = 0;
unsigned long countLines = 0;

//Atribui
CGSize sz = [UIScreen mainScreen].bounds.size;
wScreen = sz.width;
hScreen = sz.height;
UIFont *font = [UIFont systemFontOfSize:FONT_SIZE];

// version < 7.0
IF (SYSTEM_VERSION_LESS_THAN(iOS7_0))
{

//Adriano suprime warning//
#pragma clang diagnostic Push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//Adriano suprime warning//

CGSize withinSize = CGSizeMake(wScreen - LEFT_RIGTH_BORDER_EXTERN - LEFT_RIGTH_BORDER_INTERN, FLT_MAX);
CGSize size = [msg sizeWithFont:font constrainedToSize:withinSize lineBreakMode:NSLineBreakByWordWrapping];

wLabel = size.width + LEFT_RIGTH_BORDER_INTERN;
hLablel = size.height + TOP_BOTTOM_BORDER_INTERN;

}

ELSE IF (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(iOS7_0))

{

CGSize size2 = [msg boundingRectWithSize:CGSizeMake(wScreen - LEFT_RIGTH_BORDER_EXTERN - LEFT_RIGTH_BORDER_INTERN, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName : font

}

// version >= 7.0
context:nil].size;
wLabel = size2.width + LEFT_RIGTH_BORDER_INTERN;
hLablel = size2.height + TOP_BOTTOM_BORDER_INTERN;

}

ELSE

{

countLines = (([msg Length])/ MAX_CHAR_LINHA )+ 1;

IF (countLines > 1 )
{

wLabel = MAX_LENGTH_LABEL;

}
ELSE
{

wLabel = ([msg Length] * 8) + FONT_SIZE;

}

};

//Meio do iphone 3 e 4 = W: 160 e H: 240
countLines = 30;
xLabel = (wScreen / 2) - (wLabel / 2);
yLabel = (hScreen / 2);

//Desenha retangulo do Toast
CGRect rect = CGRectMake(xLabel,yLabel,wLabel,hLablel);
t.label = [[[UILabel alloc] initWithFrame:rect] autorelease];
t.label.text = msg;
t.label.textColor = [UIColor whiteColor];
t.label.font = [UIFont systemFontOfSize:FONT_SIZE];
t.label.textAlignment = NSTextAlignmentCenter;
t.label.backgroundColor = [UIColor BACKGROUND_COLOR];
t.label.numberOfLines = countLines;

RETURN t;

}


- (void)showOnView:(UIView *)view
{
[self.label setAlpha:0];
[view addSubview:self.label];

[UIView animateWithDuration:FADE_IN_DURATION
animations:^{
[self.label setAlpha:1];
}

completion:^(BOOL finished) {
[UIView animateWithDuration:FADE_OUT_DURATION
delay:self.Delai
options:0
animations:^{ [self.label setAlpha:0]; }
completion:^(BOOL finished) {}
];
}];
}
@END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:05
void IOS_BloqueiaTela(BOOL bStatus)
{
// Changes the status of the autolock
[[UIApplication sharedApplication] setIdleTimerDisabled:bStatus];
}


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:05
void IOS_LerTexto(NSString *const sMsg)
{
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:sMsg];
AVSpeechSynthesizer *synth = [[[AVSpeechSynthesizer alloc] init] autorelease];
[synth speakUtterance:utterance];
}


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:06
void IOS_ToastAffiche(NSString *sMessage, void *pclView, int nDelai)
{
WDToast *pclToast = [WDToast toastWithMessage:sMessage delay:nDelai];
[pclToast showOnView:(UIView *)pclView];
}


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:08
Procedure WS_Rota_PlotarPontos(GoogleMapsPoint is string,distancia is int)

//Market_Itinerary
//GoogleMapsPoint ="lsczClaqkHFcBUGcASmAOuAKM`DW~GMzDa@rKo@hQ]~KzF\TuHHoBFeBa@c@eBgB"
//GoogleMapsPoint = "znizCzumjH_CYoDi@}AUYCs@Q"
//GoogleMapsPoint = "lsczClaqkHFcB"
//encoded ="znizCzumjH_CYoDi@}AUYCs@Q"

//goulin
// p1 is geoPosition
// p2 is geoPosition
// p1..Latitude = -25.4189648
// p1..Longitude = -49.2443820
//
// p2..Latitude = -25.4189929
// p2..Longitude = -49.2440539

//sTempstr is string = WS_CEP_Rota("doutor goulin,1661,curitiba,PR ","leonidas Alves cordeiro,285,piraquara,pr","")
//GoogleMapsPoint = GloRotaEncode


ok is boolean = False
nomeMaker is int

IF Length(GoogleMapsPoint) > 6


x is int = 1

//MapDeleteAll(WIN_Taxi62.ControleMapa)

nInicial is int = 0
arrayPoints is array of LatLng

pointA is LatLng
pointB is LatLng

arrayPoints = WS_Rota_DecodePoints(GoogleMapsPoint)

WHILE( x < ArrayCount(arrayPoints))

pointA = arrayPoints[x]
pointB = arrayPoints[x+1]
nomeMaker++
MarkerPonto..Position.Latitude = pointA.Latitude
MarkerPonto..Position.Longitude = pointA.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+nomeMaker
MarkerPonto..Description = "Itinerary"+nomeMaker
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)

WS_Rota_PlotarXLinhas(pointA,pointB,distancia)

x++

END


MarkerPonto..Position.Latitude = pointB.Latitude
MarkerPonto..Position.Longitude = pointB.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+x
MarkerPonto..Description = "Itinerary"+x
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)



IF pointB.Latitude <> "" AND pointB.Longitude <> "" THEN
ok = True
ELSE
ok = False
END

END

RESULT (ok)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
2 969 messages
Popularité : +89 (91 votes)
Posté le 24 août 2017 - 18:09
Procedure WS_Rota_PlotarXLinhas(pointA is LatLng , pointB is LatLng, distancia is int)

IF pointA.Latitude <> "" AND pointB.Latitude <> "" AND pointA.Longitude <> "" AND pointB.Longitude <> ""

CountPoints is int
nomeMaker is int
metrosEntrePontos is int = 10

IF distancia>= 20000 THEN
metrosEntrePontos = 50
ELSE IF distancia>= 15000 THEN
metrosEntrePontos = 40
ELSE IF distancia>= 10000 THEN
metrosEntrePontos = 30
ELSE IF distancia>= 5000 THEN
metrosEntrePontos = 20
END



//
c1 is real = pointA.Latitude - pointB.Latitude
c2 is real = pointA.Longitude - pointB.Longitude


CountPoints = Root(Power(c1,2) + Power(c2,2)) * (metrosDistancia / metrosEntrePontos)

IF CountPoints = 1 THEN CountPoints = 2
IF CountPoints > 0 THEN

c1 = c1 / CountPoints
c2 = c2 / CountPoints

END

WHILE (CountPoints > 1)

CountPoints--
pointA.Latitude -= c1
pointA.Longitude -= c2
nomeMaker++

//plota no mapa
MarkerPonto..Position.Latitude = pointA.Latitude
MarkerPonto..Position.Longitude = pointA.Longitude
MarkerPonto..Image = WIN_Taxi62.IMG_Ponto
MarkerPonto..Name = "Itinerary"+ nomeMaker
MarkerPonto..Description = "Itinerary"+ nomeMaker
MapAddMarker(WIN_Taxi62.ControleMapa , MarkerPonto)

END

END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/