Creat a link to marker, need improves
Posted: 26 Jun 2011, 13:18
I spend hours trying to find a way to create a link to open a marker on the map, it turns out that the code that does it
is part of "getPhocaMapPlgPM1()" function which create the whole map
The only idea I came up was to basically copy above code with every related variables, and put the into a new function, and this new function basically create the exactly same marker on top of the old one. Just went into the source code and copy the following section and put them into a new function
The problem is that for every marker on the map a function is required, and if any changes are made in the component, you have to change it in the function.
Is there not a better solution?
Code: Select all
google.maps.event.addListener(markerPhocaMarker1PlgPM1, 'click', function() {
infoPhocaWindow1PlgPM1.open(mapPhocaMapPlgPM1, markerPhocaMarker1PlgPM1 );
});
google.maps.event.trigger(markerPhocaMarker1PlgPM1, 'click');
The only idea I came up was to basically copy above code with every related variables, and put the into a new function, and this new function basically create the exactly same marker on top of the old one. Just went into the source code and copy the following section and put them into a new function
Code: Select all
var phocaImage7PlgPM1 = new google.maps.MarkerImage(YOUR OWN VALUE);
var phocaPoint1PlgPM1 = new google.maps.LatLng(YOUR OWN VALUE);
var markerPhocaMarker1PlgPM1 = new google.maps.Marker({
title:"YOUR OWN VALUE",
icon:phocaImage7PlgPM1,
position: phocaPoint1PlgPM1,
map: mapPhocaMapPlgPM1
});
var infoPhocaWindow1PlgPM1 = new google.maps.InfoWindow({
content:YOUR OWN VALUE
});
google.maps.event.addListener(markerPhocaMarker1PlgPM1, 'click', function() {
infoPhocaWindow1PlgPM1.open(mapPhocaMapPlgPM1, markerPhocaMarker1PlgPM1 );
});
google.maps.event.trigger(markerPhocaMarker1PlgPM1, 'click');
Is there not a better solution?