On Sep 26, 10:51 pm, Swanson <[EMAIL PROTECTED]> wrote:
> The logical thing to do would be to process the form using ajax, and
> then reload the markers using an event listener like moveend.
>
> So, for example, use the prototype library:http://www.prototypejs.org/
> and then set up a javascript function like this:
>
> <script type="text/javascript" src="http://prototypejs.org/javascripts/
> prototype.js"></script>
>
> <script type="text/javascript" language="JavaScript">
> function sendpoints()
> {
> var url = 'insert-secrets.php';
> var labelvalue = $F('label');
> var latvalue = $F('latl');
> var lngvalue = $F('lng');
> var catvalue = $F('category');
> var pars = 'label='+labelvalue+'lat='+latvalue+'lon='+lonvalue
> +'cat='+catvalue;
> var target = 'output';
> var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters:
> pars});}
>
> </script>
> <div id = "output">Any text in insert-secrets.php will appear here</
> div>
> Then, take out your
> <form action="insert-secrets.php" method="post">
> change to
> <form action="" method="t">
> and change
> <input type="submit" value="Add your location" />
> to
> <input type="submit" value="Add your location" onclick =
> "sendpoints();" />
>
> You then want to put:
> GDownloadUrl("extract-secrets.php", function(data) {
> var xml = GXml.parse(data);
> var markers = xml.documentElement.getElementsByTagName("marker");
> for (var i = 0; i < markers.length; i++) {
> var id = markers[i].getAttribute("id");
> var label = markers[i].getAttribute("label");
> var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
> parseFloat(markers[i].getAttribute("lng")));
> var category = markers[i].getAttribute("category");
> var marker = createMarker(point, label, category, id);
> map.addOverlay(marker);
> makeSidebar();
> }
> });
> into a function:
>
> function updatemarkers ()
> {
> GDownloadUrl("extract-secrets.php", function(data) {
> var xml = GXml.parse(data);
> var markers = xml.documentElement.getElementsByTagName("marker");
> for (var i = 0; i < markers.length; i++) {
> var id = markers[i].getAttribute("id");
> var label = markers[i].getAttribute("label");
> var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
> parseFloat(markers[i].getAttribute("lng")));
> var category = markers[i].getAttribute("category");
> var marker = createMarker(point, label, category, id);
> map.addOverlay(marker);
> makeSidebar();
> }
> });
>
> }
>
> and add a listener:
> Gevent.addListener(map,"moveend",function() {updatemarkers()});
>
> ========================================================
>
> I haven't actually tested any of this code, but that's how i would do
> it.
Ralph, thank you for your reply. I had seen the tutorial before but
not your map. It is always nice to see a working map.
When testing your map I like the part where the reply message appeared
as opposed to going to the php page. This is the first problem I
would like to correct on my map. Not having access to your code, I am
still unsure how to prevent my map going to the php page. I will
experiment with the response code equaling 200 to see if that will
help.
Your map did not refresh after I entered my data or after I hit the
“Update map …” but that may be due to the part of the world in which I
live where we pay for high-speed and settle for dial-up speed. Things
like that can sometimes take forever. However, when I refreshed the
browser my marker was there which is what I expected and desire to
happen on my map. Does the “Update map …” do a refresh?
Thanks again for your response.
Swanson, thank you also for your response and all of the coding.
Looking at your coding it appears that a lot of it is uploading and
downloading of the markers. As I stated, I am satisfied with how my
uploading and down loading works for now but taking a second look I
see that I have made a fatal error. I did not test my map in IE
before posting this question and now I see that it does not show the
markers in IE although it works fine in FF.
Rats, I hate it when that happens.
I hope that I do not have to replace my code with what you have
provided to solve my problem. I will however if that is what it
takes.
I will take a careful look at your code to see if it works for me.
Thanks again.
For you that are looking at the map in FF, is there a simpler solution
out there?
Les
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---