javascript - Google Maps API - Map.data scope issue -
I am trying to add a geo-layer layer in Google Maps (v3) by doing the following:
< Pre> imageActive = {url: "images / target_red.png", original: new google.maps.Point (0,0), anchor: new google.maps.Point (11, 11), // // active Marker image JQuery.getJSON ('home / gcpts / geojson.php', function (data) {points = map.data.addGeoJson (data); console.log (digits); // this works}}; Map.data.setStyle ({clickable: true, dragable: incorrect,}); Map.data.addListener ('click', function) {setActiveImage (event);}) Function setActive image (event) {for (var i = 0; i & lt; points.length; i ++) {/ Can not read / "length" of the undefined points [i] .revertStyles (); } Map.data.overrideStyle (event.feature, {icon: imageActive,}); }
However, when I try to repeat through the "numeral" variable, I do not see "see". I get mainly undefined, or if I try to call the number of points (points.length), then it does not exist.
If I do console.log in jQuery function, then I can see all the attributes inside the variable. If I keep it outside, then I can not see it. Is there something that I'm missing about the scope?
It is my hope that I can set up a "click" event and use the event. Feature override style When a different feature is clicked, the style is removed from other GeoJon features and overrides the new clicked feature.
It seems that it should work fine, but I do not know this
(Besides, I am using jQuery in the "no conflicts" mode. All your variables are scoped globally because you have var
Comments
Post a Comment