Page 2 of 4

How do I add a marker to a google map?

Posted: Fri Mar 16, 2012 4:28 pm
by Jgc

Oh sorry, I forgot to add the code Im using. Here it is -

alert("Searching your location, please wait!");
break;
var map = Tiggr('googlemap1');
map.options['address'] = location.val();
map.refresh();

var location = new google.maps.LatLng(-25.363882,131.044922);

var myOptions = {
zoom: 4,
center: location,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map($('div[dsid="mapa"]').get(0), myOptions);

var marker = new google.maps.Marker({
position: location,
map: map,
title:"Hello World!"
});


How do I add a marker to a google map?

Posted: Fri Mar 16, 2012 4:29 pm
by Jgc

The above is just for testing purposes, once I get it fully working I will modify it accordingly.


How do I add a marker to a google map?

Posted: Fri Mar 16, 2012 5:01 pm
by maxkatz

You don't need the break statement. I don't know why it's invoked multiple times - you will see the alert dialog the same number of times you invoke the entire code.


How do I add a marker to a google map?

Posted: Fri Mar 16, 2012 8:53 pm
by Jgc

I see. What would you suggest as far as letting users know the app is working when they click the button? I guess Im asking for some sort of notification or alert to let the user know that the geolocation is working. I noticed when i use the app it takes about 5-8 seconds for the map to change, and sometimes i dont know if its working. My only indicator is the phones built in geolocation icon at the tp of my screen, but not all phones may have a visual indicator, so i wanted to create one.

What would you suggest?


How do I add a marker to a google map?

Posted: Fri Mar 16, 2012 9:22 pm
by maxkatz

You could place a small Ajax loader, as an example.


How do I add a marker to a google map?

Posted: Sat Mar 17, 2012 4:13 am
by Jgc

I could....if i were familiar with ajax....Is ajax easy to learn? I sorta wanted to keep everything javascript and/or jquery based.... :-\


How do I add a marker to a google map?

Posted: Sat Mar 17, 2012 6:51 pm
by Jgc

Is their a way to use this code without an ajax loader? Can I use this inside my GeoLocation component? I notice you say a GeoLocation is not needed for this, just a map.....but where does the code go in that case?

Yes im an inexperienced JS dev but im learning!^^


How do I add a marker to a google map?

Posted: Sat Mar 17, 2012 6:58 pm
by Jgc

Im also wondering if its possible to use a local file.....So like if I used a .txt file with the script inside is their a wy to "hook" it to the map?

This way I could easily update the .txt file without going into the code all the time on the app itself....Please let me know if and how this could be possible. I have a few ideas but would appreciate a professional perspective on the matter.

Thanks I realy love Tiggzi!!!!!!


How do I add a marker to a google map?

Posted: Sat Mar 17, 2012 7:17 pm
by maxkatz

Ajax, jQuery... it's all JavaScript based.


How do I add a marker to a google map?

Posted: Sat Mar 17, 2012 7:17 pm
by maxkatz

The Ajax loader is only for showing the user something is happening.. you don't have to use it.