A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] I need Help and Direction with a xml Store Locator with a link to google maps

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    23

    resolved [RESOLVED] I need Help and Direction with a xml Store Locator with a link to google maps

    I need help and direction with a XML Store Locator with a link to google maps. Basically, I was asked by my company to make a store locator for our website but I only have basic knowledge of Actionscript and XML. What I would like to do is have an Input text box with a search button and an dynamic text box to display the results. Whatever is typed into the input box is what I want to search the XML file for.

    I would like to have 6 variables to search for (StoreName, Address, City, StateShort, StateLong , ZipCode).

    Now For example if someone typed "CA" or "California" all entries that have CA as its StateShort or California as it's StateLong atribute would be displayed, something for the rest as well.

    In addition to displaying the info in the text box I would like the output to be links so that I can link the location to a popup of the location in google maps.

    Here is how I think the XML file should look:

    Code:
    <StoreLocations>
        <StoreEntry StoreName="Joes Hardware" Address="1234 Main Street" City="Somewhere USA" StateShort="CA" StateLong="California" ZipCode="99999">
        Joes Hardware    1234 Main Street    Somewhere USA    CA    99999
            <link>http://maps.google.com/maps?q=1600+Amphitheatre+Pkwy,+Mountain+View,+CA+94043,+USA&sa=X&oi=map&ct=title</link>
        </StoreEntry>
    </StoreLocations>
    The google maps link I used is google's HQ

    The Problem is I really don’t know how to do this, Can anyone help or point me in the right direction? I have read and tried tutorials, however I still cant figure out how to go about this.

    Either way when I complete this project I will submit a working copy to the flash community because I have seen other people looking to do something similar to what I am trying to do.

  2. #2
    Junior Member
    Join Date
    Nov 2007
    Posts
    23

    An update

    Here is my Actionscript so far, Please note I didn't write this code I copied and modified it to my needs. I'm not this knowledgeable about AS.

    Code:
    myXML = new XML(); 
    myXML.ignoreWhite = true; 
    myXML.load("test.xml"); 
    
    myXML.onLoad = function(success) 
    { 
        if (success) parseXML(this); 
    }; 
    
    function parseXML(xml) 
    { 
        _global.Data = new Array(); 
        aNode = xml.childNodes; 
        len = aNode.length; 
    
    	for (var n=0;n!=len;n++) 
    	{ 
    		obj = {}; 
    
    
    		obj.StoreName = aNode[n].attributes.StoreName; 
    		obj.Address = aNode[n].attributes.Address; 
    		obj.City = aNode[n].attributes.City;
    		obj.StateShort = aNode[n].attributes.StateShort; 
            obj.StateLong = aNode[n].attributes.StateLong; 
    		obj.ZipCode = aNode[n].attributes.ZipCode; 
    
    		Data[n] = obj; 
    		
    		Data[x] = Data[n];
    		
    		tracer();  
    	} 
    	  
    } 
    
    
    
    function tracer()
    { 
    	trace(Data[x].StoreName + " " +Data[x].Address + " " + Data[x].City + " " + Data[x].StateShort + " " + Data[x].StateLong + " " + Data[x].ZipCode ); // vehicles 
    
    };
    And here is the "new" version of my XML file, I made a revision.

    Code:
    <StoreEntry StoreName="Joes Hardware" Address="1234 Main Street" City="Somewhere USA" StateShort="CA" StateLong="California" ZipCode="99999" />
    <StoreEntry StoreName="Jims Bakery" Address="4321 Muffin Street" City="Elsewhere USA" StateShort="MA" StateLong="Massachusetts " ZipCode="99991" />
    <StoreEntry StoreName="Jacks Bate and Tackle" Address="98762 Fishhook Ave." City="A Place USA" StateShort="FL" StateLong="Florida " ZipCode="11111" />
    </StoreEntry>

    What I need to figure out now is how to create an array and place all of the attributes into it so that I can put them into a dynamic text box.

    I also need to figure out how to create the url link in the XML file so that when an entry is clicked on it will popup with a google map to the location.

    On top of that I need to figure out how to Parse / Search the XML file so that only the entries that match the criteria inputted by the user are displayed.

    Any advice any one could give me would be very helpful. Hopefully someone can point me in the right direction.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Nov 2007
    Posts
    23

    Another Update

    Ok Almost Completely New AS and 100% new XML, Now however I can display an entry in the XML in flash. However it keeps displaying only the last one. I think I am going to need assistance fixing this.

    I am still trying to implement the search feature but I still don’t know how yet. And last but not least, making the text clickable.

    My guess is that I need to make invisible movie clips and place them over the text box in rows. Then add some sort of generic on (release) function that grabs the link of the line of text beneath it. Anyway here is the new AS:

    Code:
    var myXML:XML = new XML();//creating XML object
    
    var StoreName_arr:Array=new Array()//array objects to hold StoreName data from xml
    var Address_arr:Array=new Array()//array objects to hold Address data from xml
    var City_arr:Array=new Array()
    var StateShort_arr:Array=new Array()
    var StateLong_arr:Array=new Array()
    var ZipCode_arr:Array=new Array()
    
    var storeName;
    
    
    myXML.ignoreWhite = true;//white spaces will be discarded
    
    
    myXML.onLoad = function() 
    {//function will be call when xml file data loaded into xml object 
    
    	var full_arr:Array=this.firstChild.childNodes//here we have array of child nodes
    
    	var len:Number=full_arr.length-1//getting the no of child nodes
    	for(var i:Number=0;i<=len;i++)//looping trough the values
    	{
    		StoreName_arr[i]=full_arr[i].childNodes[0].firstChild//storing StoreName values in array
    		Address_arr[i]=full_arr[i].childNodes[1].firstChild //storing Address details in array 
    		City_arr[i]=full_arr[i].childNodes[2].firstChild
    		StateShort_arr[i]=full_arr[i].childNodes[3].firstChild
    		StateLong_arr[i]=full_arr[i].childNodes[4].firstChild
    		ZipCode_arr[i]=full_arr[i].childNodes[5].firstChild
    	
    		trace([StoreName_arr[i],Address_arr[i],City_arr[i],StateLong_arr[i],ZipCode_arr[i],newline]);
    
    		displaytxt.text = StoreName_arr[i] + "          " + Address_arr[i]  + "          " + City_arr[i]  + "          " + StateLong_arr[i] + "          " + ZipCode_arr[i];
    	}
    	
    
    }
    
    
    myXML.load("sample.xml");//loading the xml file data into xml object
    And here is the new XML:

    Code:
    <?xml version="1.0"?>
    <root>
    	<StoreEntry>
    		<StoreName>Joes Hardware</StoreName>
    		<Address>1234 Main Street</Address>
    		<City>Somewhere USA</City>
    		<StateShort>CA</StateShort>
    		<StateLong>California</StateLong>
    		<ZipCode>99999</ZipCode>
    		<Link>http://maps.google.com</Link>
    	</StoreEntry>
    	<StoreEntry>
    		<StoreName>Jims Bakery</StoreName>
    		<Address>4321 Muffin Street</Address>
    		<City>Elsewhere USA</City>
    		<StateShort>MA</StateShort>
    		<StateLong>Massachusetts</StateLong>
    		<ZipCode>99991</ZipCode>
    		<Link>http://maps.google.com</Link>
    	</StoreEntry>
    	<StoreEntry>
    		<StoreName>Jacks Bate and Tackle</StoreName>
    		<Address>498762 Fishhook Ave.</Address>
    		<City>A Place USA</City>
    		<StateShort>FL</StateShort>
    		<StateLong>Florida</StateLong>
    		<ZipCode>11111</ZipCode>
    		<Link>http://maps.google.com</Link>
    	</StoreEntry>
    </root>

    As before, seeing that I am in uncharted territory (for me), any help will be really appreciated
    Attached Files Attached Files

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i have attached a simple Flash 8 file that addresses one of
    your criteria - clickable links

    also, in a recent thread, there is a file dealing with
    an xml search, can you make use of that method ??

    http://board.flashkit.com/board/showthread.php?t=755418
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    23
    Wow! Thank you so much! This definitely helps, and I am looking at the xml search engine. It is in many ways what I am trying to do. However I think it will take me a while to really understand how it works completely before I can try implement something like it. But it is definitely a step in the right direction. I really appreciate your assistance.

    I will leave this thread open for a while just in case I have more questions, and when I am done I will post a finnished and working copy.

  6. #6
    Junior Member
    Join Date
    Nov 2007
    Posts
    23

    Thank you

    Ok well to be honest, I kind of understand how the posted example works. However the example posted serves my purposes without modification so I cant post a working xml search engine since it has been done and I cant do better. Thank you a_modified_dog and shaunfreeman.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center