Jump to content

google maps .AU3 question


 Share

Recommended Posts

Trying to get some on click goodness for the markers. I have been playing with addlistener, but lack the skills and understanding to specify the marker as an object independent of the entire map. In this example:

hit the food button and it pops two eatery icons, i would like to be able to display the address when they click on the icon. I have mastered getting it to appear when they click on the button or when they click anywhere on the map, but am the fail at getting the function confined to the marker.

#Include <GuiListView.au3>
#Include <GuiListBox.au3>
#include <GoogleMaps.au3>
#include <File.au3>


Global Const $EN_SETFOCUS = 0x100
Dim $msg, $gmap, $distance, $duration
Global $main_gui, $set_view_button, $set_view_input, $zoom_view_button, $zoom_view_input, $add_marker_button, $add_marker_input, $instruction

; Setup Main GUI
$main_gui = GUICreate("Google Maps Example", 800, 600, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX))
$gmap_ctrl = _GUICtrlGoogleMap_Create($gmap, 0, 0, 800, 479, "4001 Industrial Blvd, Temple, Tx", 12, True, 0, 2, 1, 1)
GUICtrlSetResizing($gmap_ctrl, $GUI_DOCKTOP)

$main_tab = GUICtrlCreateTab(1, 455, 800, 120)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)

$directions_tabitem = GUICtrlCreateTabItem("Directions")
;~ $Flight_button = GUICtrlCreateButton("View Flights", 10, 525, 80, 20)
;~ GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
$add_marker_button = GUICtrlCreateButton("Food" , 10, 525, 80, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
$Hotel_button = GUICtrlCreateButton("View Hotels", 10, 505, 80, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
$get_route_button = GUICtrlCreateButton("Route Info", 10, 485, 80, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
GUICtrlCreateLabel("from", 100, 485, 30, 20)
$start_route_input = GUICtrlCreateInput("Temple, Tx", 130, 485, 180, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
GUICtrlCreateLabel("to", 100, 505, 20, 20)
$end_route_input = GUICtrlCreateInput("Minute Maid Park, Houston, TX", 130, 505, 180, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
GUICtrlCreateLabel("Distance (mi)", 320, 485, 80, 20)
$distance_input = GUICtrlCreateInput("", 390, 485, 50, 20)
GUICtrlCreateLabel("Duration (min)", 320, 505, 80, 20)
$duration_input = GUICtrlCreateInput("", 390, 505, 50, 20)
$print_directions = GUICtrlCreateButton("< Print", 705, 530, 80, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)
$directions_listview = GUICtrlCreateListView("Step #|Instruction|Distance (mi)|Duration (min)", 450, 485, 250, 85)
_GUICtrlListView_SetColumnWidth($directions_listview,0,55)
_GUICtrlListView_SetColumnWidth($directions_listview,1,350)
_GUICtrlListView_SetColumnWidth($directions_listview,2,90)
_GUICtrlListView_SetColumnWidth($directions_listview,3,90)


GUICtrlCreateTabItem("");


$close_button = GUICtrlCreateButton("Close (Esc)", 705, 550, 80, 20)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER)

dim $main_gui_accel[1][2]=[["{ESC}", $close_button]]

; Show Main GUI
GUISetState(@SW_SHOW)
GUISetAccelerators($main_gui_accel)

;~ GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

; Main Loop
while 1

    if $msg = $get_route_button Then

        _GUICtrlGoogleMap_AddRoute($gmap, GUICtrlRead($start_route_input), GUICtrlRead($end_route_input), 0)
        $instruction = _GUICtrlGoogleMap_GetRoute($gmap, GUICtrlRead($start_route_input), GUICtrlRead($end_route_input), $distance, $duration, 0)
        GUICtrlSetData($distance_input, $distance)
        GUICtrlSetData($duration_input, $duration)
        _GUICtrlListView_BeginUpdate($directions_listview)
        _GUICtrlListView_DeleteAllItems($directions_listview)

        if IsArray($instruction) Then

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




For $k = 0 to ubound($instruction) - 1

$strinstruction = string($instruction[$k][0])
$first = stringsplit($strinstruction, "<b>" , 2)


$slash = _arrayfindall ($first , '/')


For $i = 0 to ubound($slash) - 1
    If $i <> 0 Then
        $slash[$i] = ($slash[$i]) - $i
        Endif
_ArrayDelete ($first , $slash[$i])
 Next

  $divs = _arrayfindall ($first , 'div style="font-size:0.9em"')
 For $i = 0 to ubound($divs) - 1
    If $i <> 0 Then
        $divs[$i] = ($divs[$i]) - $i
        Endif
_ArrayDelete ($first , $divs[$i])
 Next

   $divclose = _arrayfindall ($first , '/div')
 For $i = 0 to ubound($divclose) - 1
    If $i <> 0 Then
        $divclose[$i] = ($divclose[$i]) - $i
        Endif
_ArrayDelete ($first , $divclose[$i])
 Next

 $blanks = _arrayfindall ($first , '')
 For $i = 0 to ubound($blanks) - 1
    If $i <> 0 Then
        $blanks[$i] = ($blanks[$i]) - $i
        Endif
_ArrayDelete ($first , $blanks[$i])
 Next

;~ _ArrayDisplay ($first)


$StrInstruction = _ArrayToString ($first , '')
;~ msgbox (0, '' , $strInstruction)

Global $fullstr

$fullstr &= ':::   ' & $strinstruction & @CRLF


$instruction[$k][0] = $strInstruction

Next



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



            for $instr_num = 0 to (UBound($instruction) - 1)

                GUICtrlCreateListViewItem(($instr_num + 1) & "|" & $instruction[$instr_num][0] & "|" & $instruction[$instr_num][1] & "|" & $instruction[$instr_num][2], $directions_listview)
            Next
        EndIf

        _GUICtrlListView_EndUpdate($directions_listview)
    EndIf

    if $msg = $Hotel_button Then

$string = "http://www.hotels.com/search/searchmap.html?ar=HomePage%3A%3ANoSuggest&cd=10-22-10&dd=10-23-10&dn=houston&dst=1.0&nr=1&pn=1&r=2&rl=destination%3A1644299%3AEXACT_RED%3AHIGH&so=BEST_SELLER&vt=MAP"
$year = stringtrimleft (@Year , 2)
$datestring = @MON & "%2F" & @MDAY & "%2F" & $year
$dashdatestring = @MON & "-" & @MDAY & "-" & $year
$dashnextday = @MON & "-" & @MDAY + 1 & "-" & $year
$nextday = @MON & "%2F" & @MDAY + 1 & "%2F" & $year
$stringLocArrDep = StringRegExpReplace ($string, "cd=10-22-10&dd=10-23-10&dn=houston" , "cd=" & $dashdatestring & "&" & "dd=" & $dashnextday & "&" & "dn=" & GUICtrlRead($end_route_input))
ShellExecute ("iexplore.exe" , $stringLocArrDep)
    EndIf


if $msg = $print_directions Then

        if Not IsArray($instruction) Then
            msgbox (0, '' , "no directions are available yet")

        Else


$file = @ScriptDir & "\Directions from " & guictrlread($start_route_input) & " to " & guictrlread($end_route_input) & ".txt"

    $directionfile = FileOpen ($file , 10); & " ----> " & guictrlread($end_route_input) & ".txt", 10)

FileWrite ($directionfile, $fullstr)
sleep (500)
FileClose ($directionfile)
$print = _fileprint ($file)
If $print Then
    MsgBox(0, "Print", "The file was printed.")
Else
ShellExecute ($file)
EndIf
EndIf
Endif

    if $msg = $add_marker_button Then

        $marker_icon_url = ""

            $marker_icon_url = "http://www.google.com/mapfiles/markerF.png"

        _GUICtrlGoogleMap_AddMarker($gmap, "3687 S. General Bruce Drive, Temple, TX 76504", "http://media3.px.yelpcdn.com/bphoto/uKtkbq1UORNz40GzJTIC5w/ss")

        _GUICtrlGoogleMap_AddMarker($gmap, "1808 SW H K Dodgen Loop, Temple, TX 76504 ", "http://media3.px.yelpcdn.com/bphoto/u9i44PvKEUdvJlDfXQkiFg/ss")

        Endif


    If $msg = $GUI_EVENT_CLOSE or $msg = $close_button Then

        ExitLoop
    EndIf

    $msg = GUIGetMsg()
WEnd

GUIDelete()

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16) ; high word
    Local $nID = BitAND($wParam, 0xFFFF) ; low word
    Local $hCtrl = $lParam

    Switch $nID

        Case $set_view_input

            Switch $nNotifyCode

        Case $EN_SETFOCUS

                    GUICtrlSetState($set_view_button, $GUI_DEFBUTTON)
            EndSwitch


        Case $zoom_view_input

            Switch $nNotifyCode

                Case $EN_SETFOCUS

                    GUICtrlSetState($zoom_view_button, $GUI_DEFBUTTON)
            EndSwitch

        Case $add_marker_input

            Switch $nNotifyCode

                Case $EN_SETFOCUS

                    GUICtrlSetState($add_marker_button, $GUI_DEFBUTTON)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...