Sign in to follow this  
Followers 0
rootx

Google Maps Lat Long

3 posts in this topic




Check the forum 'Examples' section for "Google Maps" Udf and "_Mouse_Udf".

 

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

On 16/11/2016 at 0:21 AM, PACaleala said:

Check the forum 'Examples' section for "Google Maps" Udf and "_Mouse_Udf".

 

Ok.... I read and I write my test code 4me and 4 the others users... but how can I intercept the event click inside the map???

;ROOTX

#include <Array.au3>
#include <Google Maps.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include "_Mouse_UDF.au3"

Global $main_gui, $set_view_button, $set_view_input, $zoom_view_button, $zoom_view_input, $add_marker_button, $add_marker_input
_Mouse_RegisterEvent($EVENT_MOUSE_MOVE, "UpdateOnMove") ; this will only update the data on the label whenever the mouse moves, no more label flickering!
_Mouse_RegisterEvent($EVENT_PRIMARY_DBLCLICK, "CreateNewSquare", __ArrayCreate(50, 25)) ; create a random square somewhere on the GUI with 50x25 with and height
_Mouse_RegisterEvent($EVENT_MIDDLE_RELEASED, "RemoveNewSquareEvent") ; removes the create new square event once triggered



$map = GUICreate("Google Maps", 800, 700, -1, -1)
$country= GUICtrlCreateInput("Italy", 24, 620, 249, 21)
$city = GUICtrlCreateInput("Milano", 24, 645, 249, 21)
$addr = GUICtrlCreateInput("Via Cavour 1", 24, 670, 249, 21)
$start = GUICtrlCreateButton("Start", 280, 620, 249, 25)
Global $hLabel = GUICtrlCreateLabel("", 550, 620, 130, 50)

global $myaddress = GUICtrlRead($country)&" , "&GUICtrlRead($city)&" , "&GUICtrlRead($addr)

Global $gmap = _GUICtrlGoogleMap_Create($map, 5, 5, 790, 590,$myaddress, 18,1, True, False, 0, 1, 1,0,0,"it","C")
_GUICtrlGoogleMap_ViewLocation($map, $myaddress,  18,  1)
GUICtrlSetResizing($gmap, $GUI_DOCKTOP)

GUISetState(@SW_SHOW)

While 1
    While _Mouse_Update()
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $start
                $newadd = GUICtrlRead($country)&" , "&GUICtrlRead($city)&" , "&GUICtrlRead($addr)
                _GUICtrlGoogleMap_ViewLocation($map,$newadd,  18,  1)

        EndSwitch
    WEnd
WEnd

Func UpdateOnMove()
    Local $iHex = _Mouse_GetColor($COLOR_HEX) ; get the current mouse pixel color
    Local $aiRGB = _Mouse_GetColor($COLOR_RGB)
    Local $aiInverse[3] = [255 - $aiRGB[0], 255 - $aiRGB[1], 255 - $aiRGB[2]] ; invert the rgb color

    Local $sData = ""
    $sData = "Previous XY: " & $MOUSE_PREV_X & ", " & $MOUSE_PREV_Y & @CRLF
    $sData &= "Current XY: " & $MOUSE_X & ", " & $MOUSE_Y & @CRLF
    $sData &= "Velocity XY: " & $MOUSE_VEL_X & ", " & $MOUSE_VEL_Y & @CRLF
    $sData &= "Color: " & $iHex ; set $sData to some of our mouse information

    GUICtrlSetBkColor($hLabel, $iHex)
    GUICtrlSetColor($hLabel, __ConvertRGBToHex($aiInverse)) ; we use the inverted color to show a more readable text color
    GUICtrlSetData($hLabel, $sData)
EndFunc

Func CreateNewSquare($avArgs)
    Local $iWidth = $avArgs[0]
    Local $iHeight = $avArgs[1] ; notice the $avArgs here, which is '__ArrayCreate(50, 25)'

    GUICtrlCreateLabel("", Random($iWidth, 500 - $iWidth - 10, 1), Random($iHeight, 500 - $iHeight - 10, 1), $avArgs[0], $avArgs[1])
    GUICtrlSetBkColor(-1, Random(0x000000, 0xFFFFFF, 1))

    $clickpos = _GUICtrlGoogleMap_GetLatLng($myaddress); ----------------------->???? how can I listen this event from the map

    MsgBox("Position","Your position","X = "&$MOUSE_X & @CR&"Y = " & $MOUSE_Y &@CR & $clickpos[0] &@CR&$clickpos[1])
EndFunc

Func RemoveNewSquareEvent()
    _Mouse_UnRegisterEvent($EVENT_PRIMARY_DBLCLICK) ; we unregister the event and display some text, try double clicked after this text

    GUICtrlCreateLabel("Primary double click event removed!", 10, 480)
EndFunc

Func __ArrayCreate($iVal1, $iVal2 = -1, $iVal3 = -1)
    Local $avArray[3] = [$iVal1, $iVal2, $iVal3]
    ReDim $avArray[@NumParams]
    Return $avArray
EndFunc

Func __ConvertRGBToHex($aiRGB)
    Return "0x" & Hex($aiRGB[0], 2) & Hex($aiRGB[0], 2) & Hex($aiRGB[2], 2)
EndFunc

 

Edited by rootx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0