On Feb 26, 7:14 am, Rick Donohoe <[email protected]> wrote:
> Hey Guys,
>
> Corrected that but still having issuses. Current code is:
>
> function addMap(coordinates) {
>
> /*coordinates = coordinates.toString()
> alert(coordinates);
> */
> var coordinateString = "(18.66774725247165, -3.3367449040771535),
> (54.6671516, -3.3574301),(54.6750929147338, -3.3477312322021535),
> (54.6750929147338, -3.377256989038091),(54.667052323738794,
> -3.393908142602544),(54.6671516, -3.3574301),(54.6671516,
> -3.3574301),";
>
> var coordinates = coordinateString.replace(/[(]/g, "");
> coordinates = coordinates.replace(/[)],/g, "&");
>
> var temp = [];
> var temp2 = [];
>
> //split marker string into individual markers
> temp = coordinates.split("&");
>
> //split first marker into lat and lng values
> temp2 = temp[0].split(",");
>
> alert(temp2[0] + " becomes " + parseFloat(temp2[0]));
> alert(temp2[1] + " becomes " + parseFloat(temp2[1]));
>
> var latlng = new google.maps.LatLng(parseFloat(temp2[0]),
> parseFloat(temp2[1]));
>
> alert(latlng);
>
> map.setCenter(latlng);
>
> marker = new google.maps.Marker({
> position: latlng,
> map: map
> });
> marker.setMap(map);
>
> // -1 gets rid of the last string which is empty space
> for (var i = 1; i < temp.length-1; i++)
> {
> temp2 = temp[i].split(",");
> var latlng = new google.maps.LatLng(parseFloat(temp2[0]),
> parseFloat(temp2[1]));
> alert(latlng);
>
> marker = new google.maps.Marker({
> position: latlng,
> map: map
> });
> marker.setMap(map);
> }
>
> }
>
> I've but a few alerts in there so you can see what the values are when
> testing it.
I don't see the code above in the page to which you posted a link. Do
you have a link to your test map?
>
> First issue: latlng appears to be fine, but i'm sure
> map.setCenter(latlng); dosen't work. The code does not add any markers
> to the map, and it also dosen't get to the alert inside the for loop.
The map that you posted a link to adds markers and gives me alerts
(but they say "undefined")
>
> Second issue: I want to pass through coordinates into this method,
> which is exactly the same as coordinateString, but recieved from
> MySql. When I comment out coordinateString and use coordinates which
> has been passed through instead, then alert(coordinates) shows
> 'undefined', and it doesn't reach the next alert.
That is the behavior I see on your test map (in IE, doesn't work in
Chrome).
Javascript is case sensitive, latlng and latLng are different:
alert(event.latlng);
addMarker(event.latLng);
>
> Third issue: Im still having the issue were every so often (3/4 times)
> when I reload or update the page, the map doesn't load, only the grey
> canvas, and I have to restart firefox to fix it. Any ideas?
I get a grey map in Chrome every time. You seem to assume that if the
browser supports geolocation, the user will allow it. I deny it.
-- Larry
>
> Thanks guys,
>
> Rick
--
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.