Back to PhocaGalleryRenderMap class

Method exportMarker

public
exportMarker
(mixed $id, mixed $latitude, mixed $longitude, mixed $valueLat = '', mixed $valueLng = '', mixed $jFormLat = '', mixed $jFormLng = '')

Method exportMarker - Source code

public function exportMarker($id, $latitude, $longitude, $valueLat = '', $valueLng = '', $jFormLat = '', $jFormLng = '')
{
    $js = 'var phocaPoint' . $id . ' = new google.maps.LatLng(' . PhocaGalleryText::filterValue($latitude, 'number2') . ', ' . PhocaGalleryText::filterValue($longitude, 'number2') . ');' . "\n";
    $js .= 'var markerPhocaMarker' . $id . ' = new google.maps.Marker({' . "\n" . '   position: phocaPoint' . $id . ',' . "\n" . '   map: ' . $this->_map . ',' . "\n" . '   draggable: true' . "\n" . '});' . "\n";
    $js .= 'var infoPhocaWindow' . $id . ' = new google.maps.InfoWindow({' . "\n" . '	content: markerPhocaMarker' . $id . '.getPosition().toUrlValue(6)' . "\n" . '});' . "\n";
    // Events
    $js .= 'google.maps.event.addListener(markerPhocaMarker' . $id . ', \'dragend\', function() {' . "\n" . 'var phocaPointTmp = markerPhocaMarker' . $id . '.getPosition();' . "\n" . 'markerPhocaMarker' . $id . '.setPosition(phocaPointTmp);' . "\n" . 'closeMarkerInfo' . $id . '();' . "\n" . 'exportPoint' . $id . '(phocaPointTmp);' . "\n" . '});' . "\n";
    // The only one place which needs to be edited to work with more markers
    // Comment it for working with more markers
    // Or add new behaviour to work with adding new marker to the map
    $js .= 'google.maps.event.addListener(' . $this->_map . ', \'click\', function(event) {' . "\n" . 'var phocaPointTmp2 = event.latLng;' . "\n" . 'markerPhocaMarker' . $id . '.setPosition(phocaPointTmp2);' . "\n" . 'closeMarkerInfo' . $id . '();' . "\n" . 'exportPoint' . $id . '(phocaPointTmp2);' . "\n" . '});' . "\n";
    $js .= 'google.maps.event.addListener(markerPhocaMarker' . $id . ', \'click\', function(event) {' . "\n" . 'openMarkerInfo' . $id . '();' . "\n" . '});' . "\n";
    $js .= 'function openMarkerInfo' . $id . '() {' . "\n" . 'infoPhocaWindow' . $id . '.content = markerPhocaMarker' . $id . '.getPosition().toUrlValue(6);' . "\n" . 'infoPhocaWindow' . $id . '.open(' . $this->_map . ', markerPhocaMarker' . $id . ' );' . "\n" . '} ' . "\n";
    $js .= 'function closeMarkerInfo' . $id . '() {' . "\n" . 'infoPhocaWindow' . $id . '.close(' . $this->_map . ', markerPhocaMarker' . $id . ' );' . "\n" . '} ' . "\n";
    $js .= 'function exportPoint' . $id . '(phocaPointTmp3) {' . "\n";
    if ($valueLat != '') {
        $js .= '   ' . PhocaGalleryText::filterValue($valueLat) . '.value = phocaPointTmp3.lat();' . "\n";
    }
    if ($valueLng != '') {
        $js .= '   ' . PhocaGalleryText::filterValue($valueLng) . '.value = phocaPointTmp3.lng();' . "\n";
    }
    if ($jFormLat != '') {
        $js .= '   if (window.parent) window.parent.' . PhocaGalleryText::filterValue($jFormLat) . '(phocaPointTmp3.lat());' . "\n";
    }
    if ($jFormLng != '') {
        $js .= '   if (window.parent) window.parent.' . PhocaGalleryText::filterValue($jFormLng) . '(phocaPointTmp3.lng());' . "\n";
    }
    $js .= '}' . "\n";
    return $js;
}