I think all I need to do is split the string to an array:
var b = 'I am a JavaScript hacker.'
var temp = new Array();
temp = b.split(' ');
temp[0] = 'I';
temp[1] = 'am';
temp[2] = 'a';
temp[3] = 'JavaScript';
temp[4] = 'hacker.';
I'll have to try that late when I get home.
Does that sound about right?
Vince
On Tue, Jul 20, 2010 at 9:36 AM, Vincent Gee <[email protected]>wrote:
> Hello, This is a truncated version of the Google Sample Code:
>
> var beaches = [
>
> ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
> ['Maroubra Beach', -33.950198, 151.259302, 1]
> ];
>
> function setMarkers(map, locations) {
> var image = new google.maps.MarkerImage('images/beachflag.png',
> new google.maps.Size(20, 32),
> new google.maps.Point(0,0),
> new google.maps.Point(0, 32));
> for (var i = 0; i < locations.length; i++) {
> var beach = locations[i];
> var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
>
> var marker = new google.maps.Marker({
> position: myLatLng,
> map: map,
> icon: image,
> title: beach[0]
> });
> }
> }
>
> I think my problem is that I have:
>
> var beaches = "[
>
> ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
> ['Maroubra Beach', -33.950198, 151.259302, 1]
> ]";
>
> as my javascript variable because I'm generating the data in PHP, but
> passing it to Javascript and I can't do a replace(") because of my echo
> being in the double quote.
>
> So any idea of how to get rid of the quote when passing a PHP variable into
> javascript? Thanks!
>
> Vince
>
>
>
> On Tue, Jul 20, 2010 at 1:40 AM, ddoc <[email protected]> wrote:
>
>> What method to you use to add the marker?
>>
>> In version 3, you should use a var location = new
>> google.maps.LatLng(57.312139, 25.27173);
>> var marker = new google.maps.Marker({
>> position: location ,
>> map: map
>> });
>>
>> Best regards,
>> Alexandre
>>
>> On Jul 20, 10:14 am, eatdrinkthis <[email protected]> wrote:
>> > Using this as an example:
>> http://code.google.com/apis/maps/documentation/javascript/examples/ic...
>> >
>> > I was trying to format my site to move from API v2 to v3 using this
>> > format:
>> >
>> > var beaches = [
>> > ['Bondi Beach', -33.890542, 151.274856, 4],
>> > ['Coogee Beach', -33.923036, 151.259052, 5],
>> > ['Cronulla Beach', -34.028249, 151.157507, 3],
>> > ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
>> > ['Maroubra Beach', -33.950198, 151.259302, 1]
>> > ];
>> >
>> > As you can see from this one:
>> http://www.eatdrinkthis.com/map.php?cc=San+Francisco,+USA
>> >
>> > the print out on the bottom, the first string is the php variable,
>> > the second string is the javascript variable, which matches the proper
>> > format...
>> > but the map does not pick up the marks.
>> >
>> > But if I copy paste that string into a variable in Javascript (without
>> > passing a php variable to javascript) it works just fine:
>> http://www.eatdrinkthis.com/map2.php?cc=San+Francisco,+USA
>> >
>> > So yeah, I'm guessing that passing the php variable into javascript
>> > makes the variable pick up some invisible quotes, which are tricky
>> > since I'm in php and have to be careful about those double and single
>> > quotes?
>> >
>> > Any help would be most appreciated.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Maps JavaScript API v3" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-maps-js-api-v3%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>>
>>
>
>
> --
> Eat | Drink This - *share & discover the best!*
> www.eatdrinkthis.com
>
>
>
--
Eat | Drink This - *share & discover the best!*
www.eatdrinkthis.com
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.