Thanks for the response.

I'm still a bit confused as to the relationship between the marker
objects and the second object which allows for the markers to be
hidden.

I assign the JSON object to a JavaScript variable/object statically
via a long string of JSON (var = [{"name":"Site1",
"long":"-105.0"...);.  I'd like to be able to parse the JSON object
returned via the $.getJSON jQuery function and create that same string
dynamically but am having trouble bridging between the object returned
from the jQuery call and the variable assignment.

Here's the code that I'm struggling with:

<script type="text/javascript">
                //assign url to php files to query database and build json 
arrays
                var camurl="buildcamjson.php";

                //create arrays to hold marker objects for cams, public cgs and
private cgs
                var cammarkerarray = [];
                var camattributearray = [];

                //Get JSON object
                $.getJSON(camurl,function(json)
                {
                        //loop through each json object and return primary key 
and site
object creating a marker attribute for each object
                        $.each(json.campgrounds,function(i,cam)
                        {
                                //ASSIGN JSON OBJECTS TO VARIABLE HERE
                        }); //end $.each loop
                }); // end $.getJSON function
                //create array to hold public cg marker attributes
</script>

Here's the functional module with the long string statically entered
which works fine but is very poor technique:

        $(function()
        {
                //create new roadmap object in map div centered on Colorado at 
zoom
level 8
                var map = new google.maps.Map(document.getElementById('map'),
                {
                zoom: 8,
                center: new google.maps.LatLng(39.0, -105.5),
                mapTypeId: google.maps.MapTypeId.ROADMAP
                }); // end map block

                //create new infowindow object
                var infowindow = new google.maps.InfoWindow();

                //assign url to php files to query database and build json 
arrays
                var camurl="buildcamjson.php";
                var publiccgurl = "buildpubliccgurl.php";
                var privatecgurl = "buildprivatecgurl.php";

                //create arrays to hold marker objects for cams, public cgs and
private cgs
                var cammarkerarray = [];
                var publiccgmarkerarray = [];
                var privatecgmarkerarray = [];

                //create array to hold cam marker attributes
                var camattributearray = [{ "pkID":"1", 
"name":"CDOTJulesburgNorth",
"city":"Julesburg", "state":"CO", "longitude":"-102.247269",
"latitude":"40.967636", "operator":"CDOT", "url":"http://
www.cotrip.org/images/ws/camera?imageURL=72"}, three hundred
additional elements...
}];

Any help is appreciated!

Thanks!

Rick

On Feb 9, 4:37 pm, Rossko <ros...@culzean.clara.co.uk> wrote:
> What many folk would do is to create a marker object in the usual way,
> and then assign your custom data directly to it
>    var marker = new google.maps.Marker(...
>    marker.mySpecialAttribute = ...
> you can then store an array of markers in the usual way, for easy and
> direct manipulation.
>
> If you have buckets of data, you could keep that in a seperate array
> and store an index into the array on the marker proper.  Perhaps you
> already have a unique ID in your data.

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to