geo code change marker

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 31, 2011   (RSS)

By Maurice - May 30, 2011

I'm trying to change my marker with the geo plugin in but for some reason it not working.

<script type="text/javascript">
function initialize() {
var mapCanvasId = 'map_canvas';
var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
var bounds = new google.maps.LatLngBounds();
var infowindow = new google.maps.InfoWindow();
var image = 'marker.png'();
var Marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
<?php
foreach ($lstAccountsRecords as $record) {
if (!$record['latitude'] || !$record['longitude']) { continue; }
$jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .escapeJs($record['_link']). "'";
print " _geocoder_addMarker($jsFunctionArgs);\n";
}
?>

//
function _geocoder_addMarker(latitude, longitude, recordNum, detailLink) {
var latLng = new google.maps.LatLng(latitude, longitude);
var infowindowEl = document.getElementById('marker_infowindow_' + recordNum);
var marker = new google.maps.Marker({ map: map, position: latLng });
google.maps.event.addListener(marker, 'mouseover', function() {
if (infowindowEl) {
infowindow.setContent(infowindowEl.innerHTML);
infowindow.open(map, marker);
}
else {
window.location = detailLink;
}
});
bounds.extend(latLng);
}

//
map.fitBounds(bounds);
}

</script>


what am i doing wrong???
-------------------------------------------

Dropmonkey.nl

Re: [Maurice] geo code change marker

By Jason - May 30, 2011

Hi Maurice,

Markers are actually being added in the addMarker() function, so that's where you need to make the change. For example:

//
function _geocoder_addMarker(latitude, longitude, recordNum, detailLink) {
var image = 'marker.png';
var latLng = new google.maps.LatLng(latitude, longitude);
var infowindowEl = document.getElementById('marker_infowindow_' + recordNum);
var marker = new google.maps.Marker({ map: map, position: latLng, icon: image });
google.maps.event.addListener(marker, 'click', function() {
if (infowindowEl) {
infowindow.setContent(infowindowEl.innerHTML);
infowindow.open(map, marker);
}
else {
window.location = detailLink;
}
});
bounds.extend(latLng);
}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/