Using XML file in Java script to create Google Map

Hello,
I work for a non-profit in San Diego as a GIS Specialist. I have had to teach myself about some scripting to create some dynamic maps, but I am still very limited in my skills, so I have had to explore the internet in order to discover various tutorials and examples that have led me on a positive path.
Right now I am working on a Google Mash-Up that will incorporate over 14,000 records, which will appear as separate markers that will have pop-up info bubbles with additional info inside (using html), once the marker is clicked.
Here is the XML script example that is used in the tutorial I am following:
<markers>
<marker lat="43.65654" lng="-79.90138" html="Some stuff to display in the<br>First Info Window"
label="Marker One" />
<marker lat="43.91892" lng="-78.89231" html="Some stuff to display in the<br>Second Info Window"
label="Marker Two" />
<marker lat="43.82589" lng="-79.10040" html="Some stuff to display in the<br>Third Info Window"
label="Marker Three" />
</markers>
...and this is how it looks when the file is retrieved by the java script and mapped: http://econym.googlepages.com/example_map3.htm
This is the java script that creates the Google Map. I have emboldened the section of the script that retrieves the data and parses it to create the markers:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA6GoL8P5zqjQlG5A5uM1ETBSUPozAscB0cY3RG8xEGnZyeom4axRySak889rVpvHYRsV4f9OZZzbboA"
type="text/javascript"></script>
</head>
<body onunload="GUnload()">
<!-- you can use tables or divs for the overall layout -->
<table border=1>
<tr>
<td>
<div id="map" style="width: 800px; height: 1200px"></div>
</td>
<td width = 200 valign="top" style="text-decoration: underline; color: #4444ff;">
<div id="side_bar"></div>
</td>
</tr>
</table>
<noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view Google Maps, enable JavaScript by changing your browser options, and then
try again.
</noscript>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
// this variable will collect the html which will eventualkly be placed in the side_bar
var side_bar_html = "";
// arrays to hold copies of the markers used by the side_bar
// because the function closure trick doesnt work there
var gmarkers = [];
var i = 0;
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
// save the info we need to use later for the side_bar
gmarkers[i] = marker;
// add a line to the side_bar html
side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
i++;
return marker;
// This function picks up the click and opens the corresponding info window
function myclick(i) {
GEvent.trigger(gmarkers, "click");
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( 37.251699,-119.604315), 7);
*// Read the data from testXML2blackpoolformat.xml*
var request = GXmlHttp.create();
request.open("GET", "testXML2blackpoolformat.xml", true);
*request.onreadystatechange = function() {*
*if (request.readyState == 4) {*
var xmlDoc = GXml.parse(request.responseText);
*// obtain the array of markers and loop through it*
var markers = xmlDoc.documentElement.getElementsByTagName("ConnectoryRecord");
*for (var i = 0; i < markers.length; i++) {*
*// obtain the attribues of each marker*
*var lat = parseFloat(markers[i].getAttribute("lat"));*
*var lng = parseFloat(markers[i].getAttribute("lng"));*
var point = new GLatLng(lat,lng);
*var html = markers[i].getAttribute("html");*
*var label = markers[i].getAttribute("label");*
*// create the marker*
var marker = createMarker(point,label,html);
map.addOverlay(marker);
// put the assembled side_bar_html contents into the side_bar div
document.getElementById("side_bar").innerHTML = side_bar_html;
request.send(null);
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://econym.googlepages.com/index.htm
//]]>
</script>
</body>
</html>
Here is my delima--
This is the xml format that I need to use because it can accept the rest of my excel file and loop it through the 14,000+ records to create a functioning xml file. This is just a sample (2 records) of the larger file:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<ConnectoryAug2008>
<ConnectoryRecord>
     <lng>-117.03683</lng>
     <lat>32.944505</lat>
     <ConnectoryID>1</ConnectoryID>
     <Name>$2.95 Guys</Name>
     <StreetAddress>13750 Stowe Drive</StreetAddress>
     <City>Poway</City>
     <State>CA</State>
     <Zip>92064</Zip>
<Marker>White</Marker>
     <IndustryGroup>Technical Services</IndustryGroup>
     <ConnectoryProfileLink>http://connectory.com/search/profile_view.aspx?connectoryId=1</ConnectoryProfileLink>
</ConnectoryRecord>
<ConnectoryRecord>
     <lng>-117.272843</lng>
     <lat>33.13337</lat>
     <ConnectoryID>2</ConnectoryID>
     <Name>(GLDS) Great Lakes Data Systems</Name>
     <StreetAddress>5954 Priestly Drive</StreetAddress>
     <City>Carlsbad</City>
     <State>CA</State>
     <Zip>92008</Zip>
<Marker>Orange</Marker>
     <IndustryGroup>Technology</IndustryGroup>
     <ConnectoryProfileLink>http://connectory.com/search/profile_view.aspx?connectoryId=2</ConnectoryProfileLink>
</ConnectoryRecord>
</ConnectoryAug2008>
This is the tutorial where I found the formatting techniques to successfully create the large xml file that will format/convert my excel file properly: http://www.mrexcel.com/tip064.shtml
These variables should appear as html in the info bubble:
<ConnectoryID>2</ConnectoryID>
     <Name>(GLDS) Great Lakes Data Systems</Name>
     <StreetAddress>5954 Priestly Drive</StreetAddress>
     <City>Carlsbad</City>
     <State>CA</State>
     <Zip>92008</Zip>
<IndustryGroup>Technology</IndustryGroup>
     <ConnectoryProfileLink>http://connectory.com/search/profile_view.aspx?connectoryId=2</ConnectoryProfileLink>
The "Marker" variable instructs Google Maps to label the marker with a particular color. I will be so grateful to the person(s) that helps me get through this wall that I have been hitting for a long time. It's very difficult without having the luxury of peers who know about these types of issues.
Thank you!!

Here is the relationship: They both contain geographic coordinates that produce a point on a map. I will use the rest of the information in the second xml file (company name, address, link, etc.) to produce the information for the bubble that will pop up once the marker is clicked.
My problem is that I need to try to keep the second xml file in a relatively similar format, so the rest of my records will still be accepted. If I had a smaller amount of records I could place them directly into the javascript, but because there are so many records, I need to use an xml file that can be retrieved by the java script. I chose to use the second type of xml file because I can easily copy and past the 14,000+ records that are now in excel document.
After the xml issue is corrected I need to rework the javascript that is now emboldened so that it will read the new xml file correctly. I included the first xml file so that the readers will understand what type of xml format is currently being used to produce the markers in the tutorial map.

Similar Messages

  • Using xml file in java application

    How can i get the attribute name & value into my java application from a xml flie?

    read the file
    parse the contents
    store attribute name & value pairs.
    %

  • How I can create a XML file from java Aplication

    How I can create a XML file from java Aplication
    whith have a the following structure
    <users>
    <user>
    <login>anyName</login>     
    <password>xxxx</password>
    </user>
    </users>
    the password label must be encripted
    accept any suggestion

    Let us assume you have all the data from the jsp form in an java bean object..
    Now you want a xml file. This can be acheived in 2 ways
    1. Write it into a file using java.io classes. Say you have a class with name
    write("<name>"+obj.getName+</name>);
    bingo you have a flat file with the xml
    2. Use data binding to do the trick
    will recommend JiBx and Castor for the 2nd option
    Regards,
    Rajagopal

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • How & where to use Java script to create new button in object detail page

    Hi All,
    I want to create "New/Add button" in object detail page. If i am not wrong i need to use java script for that but could you please let me know how & where to use Java script to create new button in object detail page in CRMOD.
    Thanks in advance.
    Regards,
    Manish

    Any related object on the detail page should have an "Add" or "New" or both buttons by default - This is vanilla functionality and will do the required action.
    If you want to modify this behaviour and do something tricky you will potentially have to go for javascript. You should add the javascript on a custom web tab on that Object.
    Admin --> Application Customization --> Contact -->Contact Web Applet
    Now, add your javascript in the code area, after you select the type = HTML for this web applet, expose this web applet on the Contact detail layout and your javascript will be invoked whenever this page is loaded.
    Check this online document to see how javascript can be embedded in CRM on Demand http://helponmyproject.com/TTOCOD/
    Cheers!
    Royston

  • How to edit the existing data in the XML file from java programming.

    Hi all
    i am able to create XML file with the sample data as below from java programming.
    i need sample code on how to edit the existing data in the XML file?
    for example
    <?xml version="1.0"?>
       <mydata>
               <data1>
                         <key1>467</key1>
                        <name1>Paul</name1>
                        <id1>123</id1>
              </data1>
              <data2>
                         <key2>467</key2>
                        <name2>Paul</name2>
                        <id2>123</id2>
              </data2>
        </mydata>
    i am able to insert the data in the XML.
    now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code
    Regards
    Sunil
    [points will be always rewardable]

    hi
    u need a parser or validate the xml file for to read the xml file from java coding u need for this
    xml4j.jar u can download this file  from here
    http://www.alphaworks.ibm.com/tech/xml4j
    or we can use the SAX(simple API for XML)
    some sample applications for this
    http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html
    http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html
    http://www.xml-training-guide.com/e-xml44.html
    let me know u need any other info
    bvr

  • How to modify an existing xml file from java code.

    Hi
    I have worked on creating a new xml file from java code using xmlbeans.But if i try to modify an already existing file using java code I am unable to get errorfree xmlfile.
    For example if xml file(studlist.xml) is as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    Now suppose i have set name to victor using student.setName,
    and set age to 20 using setAge from javacode,
    the new xml file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    <Student>
              <Name>victor</Name>
              <Age>20</Age>
         </Student>
    As observed this is not a valid xml file.But how can i modify without any errors?

    I know it's an old post, but I found this while doing a google search for something else, and don't like to leave it un-aswered
    Just in case anyone has a similar problem... In this case the new elements have been appended outside of the root element
    What you need to do is first get the root element and then append the new children to that, there are several ways of getting the root element, which depend on what you want to do with the elements you get back here's a simple (incomplete) way.
    // gets the root element of the specified file (code not shown)
    Element rootElement= new SAXReader().read(file).getRootElement();Then just append the new elements as below (this is non-generic code and would need to be modified for your situation)
    // write a new student element
    Element student = document.createElement("Student");  // creates the new student
    rootElement.appendChild(student); // ***appends it to the root element***
    Element name = document.createElement("Name"); // creates the name element
    name.appendChild(document.createTextNode("Fred")); // adds the name text to the name element
    student.appendChild(name); // appends the name to the student
    Element age= document.createElement("Age"); // creates the age element
    age.appendChild(document.createTextNode("26")); // adds the age text to the age element
    student.appendChild(age); // appends the name to the studentThen flush ya buffers or whatever and write the file
    Edited by: Dream-Scourge on Apr 23, 2008 11:10 AM

  • Can we integrate .swf file in java script ?

    Hello Friends,
    We implemented one concept in Flex and now would like to integrate with JavaScript. Earlier we integrated an Applet code but now, we developed the concept in Flex, however, I am unable to integrate the concept in java script.
    Can anyone help me out with the procedure to integrate flex swf file in java script ?
    Here is my earlier java script code :
    var file=gup('query');
    //document.write(file);
    var prevFile=gup('prevFileName');
    //document.write(prevFile);
    document.write("<table align=\"center\"><tr><td><applet code=\"MyApplet.class\" archive=\"Visual.jar\" width=1000 height=500>");
    document.write("</applet></td></tr></table>");
    function gup( name )
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
        return results[1];
    Thanks in advance.

    What version of FlashPro are you using? If you want a self contained app that doesn't load external resources, publish an AIR app, which will work on Windows or OSX. I'm using OSX so I can't really help with .exe projector files, but it looks like the latest version of FlashPro no longer outputs projector files—I think everything is AIR now.
    If you really want to go the projector route, I'm guessing Jeffrey Smith's suggestion of finding an older version of Flash Player would be simpler.
    So for AIR, set your Publishing target to AIR for Desktop. Then under File>AIR settings:
    Output as: Application with runtime embedded
    Include files: Add all of your resources—the swf ID generated and it's resource folder
    In the Signature tab click New to create a self-signing Certificate (if you were developing commercial software you would need a third party certificate). You can save the certificate anywhere.
    When you publish you should find an AIR application file (.app) file in the directory with your .fla

  • The nicest way to generate xml-files by Java???

    I have to generate huge and quite complex xml files by Java. I have to fetch the data from a Oracle database. What I really don't know is a proper and reliable way to this? I could of course create a String and concatenate all the tags, attributes and data but it doesn't feel right. I guess this is a quite common task and there are many established ways to this by Java. My question is what is the best way to this? What is your suggestion?
    Thank you for any clues...

    Hi,
    Since you have access to the database, I think one of the best way is to create stored procedures that will generate those files for you (using SQL/XML functions preferably) and return the content to the Java caller.

  • Generation of xml file from java code

    hi,
    I want to manipulate data in a xml file with java code.I have read data from xml file and also changed it. But i am unable to covert it again in xml file from java code. Can you please tell me how i can do this?

    Let me know which parser are you using currently for reading xml files so that i assist you. For now, you can refer to STAX Parser API under this link
    http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP3.html

  • Creation of External table by using XML files.

    I am in the process of loading of XML file data into the database table. I want to use the External Table feature for this loading. Though we have the external table feature with Plain/text file, is there any process of XML file data loading into the Database table by using External table?
    I am using Oracle 9i.
    Appreciate your responses.
    Regards
    Edited by: user652422 on Dec 16, 2008 11:00 PM

    Hi,
    The XML file which U posted is working fine and that proved that external table can be created by using xml files.
    Now My problem is that I have xml files which is not as the book.xml, my xml file is having some diff format. below is the extracts of the file ...
    <?xml version="1.0" encoding="UTF-8" ?>
    - <PM-History deviceIP="172.20.7.50">
    <Error Reason="" />
    - <Interface IntfName="otu2-1-10B-3">
    - <TS Type="15-MIN">
    <Error Reason="" />
    - <PM-counters TimeStamp="02/13/2008:12:15">
    <Item Name="BBE-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="BBE-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="ES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="ES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="CSES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="CSES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="UAS-S" Direction="Received" Validity="ADJ" Value="135" />
    <Item Name="UAS-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SEF-S" Direction="Received" Validity="ADJ" Value="135" />
    </PM-counters>
    <PM-counters TimeStamp="03/26/2008:12:30">
    <Item Name="BBE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="BBE-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="ES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="ES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="SES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="SES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="CSES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="CSES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="UAS" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="UAS-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="PSC" Direction="Received" Validity="OFF" Value="0" />
    </PM-counters>
    </TS>
    </Interface>
    </PM-History>
    My problem is the Item Name and Direction the value of both(ex PSCReceived or UASReceived) will be treated as the coulmn name of the table and '0' would be the value of that column. I am confused how to create the external table creation program for that.
    I would really appreciate your responses.
    Regards

  • Accessing XML files through java

    Can any one explain me the easiest way of accessing XML files from Java.

    Hi,
    If you want to only access the XML file, use the SAX parser It will be very easy to handle and identify the element and value.
    else if u want to change the XML value also, then better go with DOM, Which has very good flexiblity.
    use according to the need, let me know if any help is required......
    With Cheers
    PrasannA

  • Debugging mode stopped automatically when using xml file load

    Dear Sir,
    I am trying to develop a new add-on using xml files for creating new forms. In fact I was using the sample code delivered with the SDK ( WorkingWithXml - under VB.NET). The Problem is that when I am in the debuging mode and after the form load. the application goes out of the debugging mode and stop action.
    In fact what i was trying to do first is to create a new menu and then when i click on this menu a new form appear but once the menu is loaded the application stop the debugging mode automatically.
    Can somebody clarify to me what I am doing wrong and why the debugging mode is stopped automatically, noting that i am still in the add-on developpement phase.
    As i mentioned above i used the WorkingWithXml sample code (VB.NET) and i have adjusted in a way to load menu and then on the menu click i load my form.
    Please advice
    Best Regards

    Hi Mary,
    Put your code between in a Try Catch block. In the Catch part use the following:
    oApplication.MessageBox("CompError: " & oCompany.GetLastErrorCode.ToString & ", " & oCompany.GetLastErrorDescription & vbCrLf & "Message: " & ex.Message)
    This should give you a clearer idea of what the error is all about.
    The most likely reason is that there is something wrong with your XML file.
    Regards,
    Vítor Vieira

  • How to use XML / XPath in JAVA (in 1.4) which third part component to use?

    How to use XML / XPath in JAVA (in 1.4)
    I'm absolutely novice in XML
    but I need to query XML using XPath
    As I understand XPath become avalible only in Java 1.5
    But I use 1.4 (project requirement)
    Which third part component could you recomend?

    Can anyone help me with this XPath query
    I get result [title: null]
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    import org.jaxen.*;
    import org.jaxen.dom.*;
    import org.jaxen.saxpath.*;
    import java.util.*;
    public class TestX {
         public void ggg() {
              try {
                   File f = new File("journal.xml");
                   DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                   org.w3c.dom.Document doc = docBuilder.parse(f);
                   XPath xpath = new DOMXPath( "/journal/article/title" );
                   List result = (List) xpath.evaluate(doc);
                   System.out.println(result.get(0));
              } catch (Exception e) {
                       e.printStackTrace();
         public static void main(String[] args) {
              TestX tx = new TestX();
              tx.ggg();
    }journal.xml
    <journal>
        <article id="article.1">
            <title>Art1</title>
            <author>
               <first>Bob</first>
               <last>McWhirter</last>
            </author>
            <text>
            </text>
        </article>
        <article id="article.2">
            <title>Art2</title>
            <author>
               <first>James</first>
               <last>Strachan</last>
            </author>
            <text>
            </text>
        </article>
    </journal>

  • Publish app that uses XML file.

    Hi, I want to create an App which uses XML file as a data source. I want that XML file is online file on my server downloaded in first use, and looking for changes every time user want to do this, so i have a legal question if apple can release my app in AppStore or they can block it?

    Thanks,
    I have legal right, this is my XML file on my server.
    My main concern is that changing XML in fact i may change entire app. And this make me think apple would not like it. So my question is: maybe someone had similar experience.

Maybe you are looking for