javascripthtmlgoogle-mapsgoogle-search-apigoogle-ajax-api

Google Search / Map Api Separating JS from Html


As my coding revolves only around one function,the function OnLoad() where the map and search is together on this function. However i was tasked to separate the Maps and Search JS and was unable to do so. Is there any tips or tricks to separating them?


Solution

  • You could separate your logic in separate .js files or in separate script blocks within the document. Or in separate functions.. Is this what you meant? What in particular are you having trouble with? Using the APIs themselves?

    *Edit: I had trouble pasting the code in here so look at the source of this file: http://www.mediafire.com/file/nnfmnnnnymt/search.html

    If you open the page and scroll down you will find the map below the search component.

    the code is separated into the functions

    initializeMap()
    

    and

    initializeSearch()
    

    This separation will work just as well into separate .js files, provided you include them in the page.