i use addresses in pimcore backend. addresses go geocoder, used lat , lon out of address. after lon , lat stored in backend (pimcore). works pretty well.
the next step give out addresses shown on map in frontend. markers set , addresses pois shown. implemented link scrolls map, sets zoom 16 , centers around poi.
my problem here last poi shown, no matter on address link click (it scrolls map , zooms in.. there last poi shown). makes me think somehow jquery.each overwrites points, last stays. if console.log lat , lon points fit , right addresses.
maybe there oversee or miss specific part vital in function. hope makes sense you, if there questions or if unspecific let know , explain more. regards, daniel
cw.map.prototype.generatemarkersfromvcard = function () { var cwmap = this; jquery('.vcard').each(function (k, v) { var id = jquery(v).data('markerid'); var vcard = v; // todo: last address shown var lat = jquery('.latitude [title]', v).attr('title'); var lon = jquery('.longitude [title]', v).attr('title'); console.log('latitude ' + lat + ', longitude ' + lon); // fallback if lat , lon if (lat && lon) { var point = new google.maps.latlng(lat, lon); var properties = { position: point, map: map, icon: " ", labelcontent: '<i class="icon-pin map-pin"></i>', labelanchor: new google.maps.point(24, 48), labelclass: "labels" // css class label }; // setting marker map var marker = new markerwithlabel(properties); cwmap.infowindow(marker, jquery('.infowindow', v).html()); markers[id] = marker; } }); return this; };
the problem when create infowindow. how google maps reference last marker.
if @ google maps example https://developers.google.com/maps/documentation/javascript/examples/event-closure
google try google.maps.event.addlistener(marker, 'click', function() in function avoid mis-referecing problem; example not work if copy code function, replacing function call. @ example issue happening.
hope helps.
Comments
Post a Comment