Hi,

The challenge is that I do not get the markers onto the map.
I'm searching the webb but without any luck.

This is what I would like to achieve:
http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/examples/simple_example.html

My problem is that I do not know what's the problem with the code and
if I have known the problem I would have solved it...:-)

I *think* there are some issues with the way the markers are iterated
through in the for-loop and in the way the are printed on the
screen...or rather...how they should be printed on the screen.

So...I'm stuck and would be sooo greatful if someone can "unstuck"
me :-))

/Nimrod

On 14 Maj, 20:10, "[email protected]" <[email protected]> wrote:
> On May 14, 10:51 am,nimrod<[email protected]> wrote:> OK, you 
> find the page at
>
> http://www.g8journey.com/destinations/destinations_main.php
>
>
>
> > I have markerCluster = new MarkerClusterer(map, markersXml);  in the
> > function that process the response from the GDownloadUrl and var
> > markerCluster; on top and outside all functions.
>
> And?
> - what is the problem?
> - did you answer this question?
>
>
>
> > >     var markersXml = [];
> > Why are you emptying the markersXml array that you just created?  The
> > above line makes markersXml.length always 0.
>
> > /Nimrod
>
> > The code is;
>
> > var markerCluster;
> > var map;
> >       function initialize() {
> >                 if(GBrowserIsCompatible()) {
> >           map = new GMap2(document.getElementById('map'));
>
> >           map.setCenter(new GLatLng(39.91, 116.38), 2);
> >           map.addControl(new GLargeMapControl());
> >           var icon = new GIcon(G_DEFAULT_ICON);
> >           icon.image = "http://chart.apis.google.com/chart?
> > cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png";
> >           GDownloadUrl("phpsqlajax_genxml2.php?bogus="+(new Date
> > ()).getTime(),processMyData); //Calls the xml-data and sends it to
> > processMYyData-function
> >         }
> >       }
> >        function createMarker(point) {
> >                                 var marker = new GMarker(point);
> >                                 var html = "<b>" + name + "</b> <br/>" + 
> > address;
> >                                 GEvent.addListener(marker, 'click', 
> > function()
> > { marker.openInfoWindowHtml(html);});
> >                                 return marker;
> >                         }
>
> >     function processMyData(data) {
> >     var xml = GXml.parse(data);
> >     var markersXml = xml.documentElement.getElementsByTagName
> > ("marker");
> >     var markersXml = [];
> >              for (var i = 0; i < markersXml.length; ++i) {
> >               var name = markersXml[i].getAttribute("id");
> >                 var point = new 
> > GLatLng(parseFloat(markersXml[i].getAttribute
> > ("lat")), parseFloat(markersXml[i].getAttribute("lng")));
> >                 var markerOnMap = createMarker(point);
> >                         markersXml.push(markerOnMap);
> >                         markerCluster = new MarkerClusterer(map, 
> > markersXml);
> >           }
> >   }
>
> > On May 14, 7:25 pm, "[email protected]" <[email protected]>
> > wrote:
>
> > > On May 14, 9:33 am,nimrod<[email protected]> wrote:
>
> > > > Hi Larry,
>
> > > > Thank you for the reply.
>
> > > > I changed the function to the below but it does not show the
> > > > markers...
>
> > > >     function processMyData(data) {
> > > >     var xml = GXml.parse(data);
> > > >     var markersXml = xml.documentElement.getElementsByTagName
> > > > ("marker");
> > > >     var markersXml = [];
>
> > > Why are you emptying the markersXml array that you just created?  The
> > > above line makes markersXml.length always 0.
>
> > > >              for (var i = 0; i < markersXml.length; ++i) {
> > > >               var name = markersXml[i].getAttribute("id");
> > > >                                 var point = new 
> > > > GLatLng(parseFloat(markersXml[i].getAttribute
> > > > ("lat")), parseFloat(markersXml[i].getAttribute("lng")));
> > > >                                 var markerOnMap = createMarker(point);
> > > >                         markersXml.push(markerOnMap);
> > > >                         markerCluster = new MarkerClusterer(map, 
> > > > markersXml);
> > > >           }
> > > >   }
>
> > > > Any ideas why?
>
> > > Not without looking at your page again
>
> > > > About the MarkerManager...do I need that one when I use the
> > > > MarkerClusterer?
>
> > > typo, I meant MarkerClusterer
>
> > > > Many thanks,
>
> > > > /Nimrod
>
> > > > On May 14, 3:45 pm, "[email protected]" <[email protected]>
> > > > wrote:
>
> > > > > On May 14, 6:29 am,nimrod<[email protected]> wrote:
>
> > > > > > Great, now I have truely learned something today :-) thank you!
>
> > > > > > I made
> > > > > >   var map;
> > > > > >   var markerCluster;
> > > > > > into global variables as you suggested and have the
> > > > > > markerCluster = new MarkerClusterer(map, markers);
> > > > > > in the processMyData-function.
>
> > > > > > Belive it or not but I do not get any erros in FF right now. On the
> > > > > > downside is that I get no markers on the map either... :-((
>
> > > > > > From the bottom and up...
>
> > > > > > 1. XML is ok:
> > > > > >   <?xml version="1.0" ?>
> > > > > > - <markers>
> > > > > >   <marker id="95" address="" lat="98.3307" lng="7.98431" type="" />
> > > > > >   <marker id="96" address="" lat="28.4198" lng="-81.5802" type="" />
> > > > > >   <marker id="97" address="" lat="56.6375" lng="16.4998" type="" />
> > > > > >   <marker id="98" address="Sea World, Orlando, FL 32821, USA"
> > > > > > lat="28.4116" lng="-81.4591" type="" />
> > > > > >   <marker id="99" address="Tract C, Virgin Islands" lat="18.3166"
> > > > > > lng="-64.9564" type="" />
> > > > > >   <marker id="100" address="78-100 Tract F, Virgin Islands"
> > > > > > lat="18.3217" lng="-64.9527" type="" />
> > > > > >   <marker id="102" address="Tract C, Virgin Islands" lat="18.3167"
> > > > > > lng="-64.9568" type="" />
> > > > > >   </markers>
>
> > > > > > 2. The XML is passed into processMyData-function which iterates
> > > > > > through it with a for-loop.
>
> > > > > > 3. For each marker in the for-loop the createMarker-function is 
> > > > > > called
> > > > > > and creates marker.
>
> > > > > but first you set the markers array to empty
> > > > >     var markers = [];
> > > > > leaving nothing to process.
> > > > > I would suggest naming the array of html elements that you get from
> > > > > your xml and the array of GMarkers with different names.
>
> > > > > Then this rather important line is commented out...
> > > > > //var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
> > > > > parseFloat(markers[i].getAttribute("lng")));
>
> > > > > You don't include the MarkerCluster "library" in your page, so
> > > > > MarkerManager is undefined.
>
> > > > >   -- Larry
>
> > > > > > 4. The marker is returned and allocated to the "var marker"
>
> > > > > > 5. markers.push(marker);
>
> > > > > > 6. markerCluster = new MarkerClusterer(map, markers);
>
> > > > > > Shouldn't this work...?
>
> > > > > > How do I go from here?
>
> > > > > > /Nimrod
>
> > > > > > On May 14, 2:28 pm, Andrew Leach <[email protected]>
> > > > > > wrote:
>
> > > > > > > On May 14, 1:17 pm,nimrod<[email protected]> wrote:
>
> > > > > > > > The GDownloadUrl(url,processMyData) gets the data from the 
> > > > > > > > specific
> > > > > > > > URL. It "send" it to the processMyData-function. That functions
> > > > > > > > process the data and should display the markers on the map.
>
> > > > > > > > Is that correct?
>
> > > > > > > Yes.
>
> > > > > > > > I've progressed one step and FF is not liking that var 
> > > > > > > > markerCluster
> > > > > > > > not is defined. I have markerCluster in the 
> > > > > > > > processMyData-function but
> > > > > > > > the map-argument is defined in the initialize()-function. Is 
> > > > > > > > that why
> > > > > > > > FF is complaining about markerCluster?
>
> > > > > > > Yes. Or nearly, anyway.
>
> > > > > > > I would suggest adding these lines outside ANY function:
> > > > > > >   var map;
> > > > > > >   var markerCluster;
> > > > > > > then move your existing lines which start like that inside the
> > > > > > > intialize() function but remove the "var" keyword.
> > > > > > >   map = new GMap2(document.getElementById('map'));
> > > > > > >   markerCluster = new MarkerClusterer(map, markers);
>
> > > > > > > What that does is make "map" and "markerCluster" into global
> > > > > > > variables, which are available to any function. They are then 
> > > > > > > assigned
> > > > > > > values in the initialize() function.
>
> > > > > > > Andrew- Hide quoted text -
>
> > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Dölj citerad text -
>
> - Visa citerad text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to