0

I'm building an android app with windev mobile. I can open a map using variables that state the address and city but i can't seem to get a marker on the map the same way. ggladdresstocoordinates doesn't work for windev mobile.

My current code is:

//MapDisplayPosition(MAP_Worklocation, Street, City, country)
MyAddress is Address
MyAddress..Street = gnWorkaddress
MyAddress..City = gnWorkplace
MyAddress..Country = "Netherlands"

// Centers the map displayed by the "MAP_Position" control from an address
MapDisplayPosition(MAP_Worklocation, MyAddress)

MAP_Worklocation..Zoom = 17

mymarker is Marker
mymarker..Position = MyAddress
MapAddMarker(MAP_Worklocation, mymarker)
Carsten
  • 1
  • 3

2 Answers2

0

after using MapDisplayPosition, the map will be centered in the searched location, then if you use MapGetPosition, it will return the coordinates. From Windev Help: MapGetPosition - "Returns the geographical position of the point located in the center of the map currently displayed in a Map control."

MyPosition is geoPosition
MyPosition = MapGetPosition(MAP_Worklocation)
EDT_Latitude=MyPosition..Latitude
EDT_Longitude=MyPosition..Longitude
  • @FranckGamess after using MapDisplayPosition, the map will be centered in the searched location, then if you use MapGetPosition, it will return the coordinates. From Windev Help: MapGetPosition - "Returns the geographical position of the point located in the center of the map currently displayed in a Map control." – Gonçalo Silva Jul 13 '18 at 11:03
  • That's fine. Can you put this directly in your answer? not in the comment. Just edit your answer. Thank you. – fgamess Jul 13 '18 at 12:22
0

I think the problem is in the MapDisplayPosition function, the second parameter must be a geoPostiion variable, as you can see in the help OR it could be a string with the address, have you tried:

sAddress is string = gnWorkaddress + ", " + gnWorkplace + ", " + "Netherlands"

MapDisplayPosition(MAP_Worklocation, sAddress)

Also, you can't assign and Address to a ..Position, you need a geoPosition variable; after centering the map with MapDisplayPosition, you can retrieve the position with:

TmpPos is geoPosition
TmpPos = MapGetPosition(MAP_Worklocation)

And then add the marker:

MyMarker is Marker
MyMarker..Position = TmpPos
MyMarker..ActionClick = ProcMarkerClick

MapAddMarker(MAP_Worklocation, MyMarker)

Try with this, I personally found a different workaround because from and address (stree, zip code, city...) wrote during a registration, I needed the gps code, so I used the Google Maps Apis:

oQuery  is httpRequest

// Replace blank spaces with +, for URL.
sTempStreet is string = Replace(MyStreet," ","+")
sTempCity is string = Replace(MyCity," ","+")

oQuery..URL     = "https://maps.googleapis.com/maps/api/geocode/json?address="+sTempStreet+",+"+sTempCity+"+"+stTempZIP+"+"+stTempCountry+",+stTempState&key=*<yourapikeyhere>*"
oQuery..Method  = httpGet

oResponse is httpResponse
oResponse = HTTPSend(oQuery)

vInfo       is Variant
vInfo = JSONToVariant(oResponse..Content)

sGPSLatitude = vInfo.results[1].geometry.location.lat
sGPSLongidute = vInfo.results[1].geometry.location.lng