I'm not really sure how you got the quotes there, but here is how I managed the
issue - as you can see, I had an array called 'nearby_info' that had
name/title, latitude and longitude in it - I just spit that out piece by piece,
as opposed to trying to print out one line with it. It's not pretty, but it i
working great. You'd do even better to write a function that you could just
shove an array into.
<script type="text/javascript">
var nearby_markers = [<?php
$i = 1;
foreach($nearby['nearby_info'] as $nearby_item){?>
['<?=addslashes($nearby_item['name_title'])?>',
<?=$nearby_item['latitude']?>, <?=$nearby_item['longitude']?>, <?=$i?>]<?php
if($i != count($nearby['nearby_info'])){ echo ', '; }
$i = $i + 1;
} ?>];
$(document).ready(function() {
showEntryGoogleMap('<?=$row['latitude']?>','<?=$row['longitude']?>','<?=addslashes($row['name_title'])?>',
nearby_markers);
});
</script>
On Jul 20, 2010, at 12:36 PM, Vincent Gee 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].
> 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
>
>
>
> --
> 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.
--
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.