Skip to content

Commit

Permalink
Added some more properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Irmscher committed Jul 21, 2016
1 parent 4543859 commit 848c871
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 14 deletions.
69 changes: 68 additions & 1 deletion Configuration/NodeTypes.GoogleMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ui:
label: i18n
icon: 'fa fa-globe'
inlineEditable: TRUE
inspector:
groups:
'properties':
Expand All @@ -15,7 +16,6 @@
'coordinates':
label: i18n
position: 10
collapsed: TRUE
properties:
height:
type: integer
Expand All @@ -27,6 +27,65 @@
group: 'properties'
validation:
'TYPO3.Neos/Validation/IntegerValidator':
type:
type: string
defaultValue: 'ROADMAP'
ui:
label: 'Type'
reloadIfChanged: TRUE
inspector:
group: 'properties'
editor: 'TYPO3.Neos/Inspector/Editors/SelectBoxEditor'
editorOptions:
values:
ROADMAP:
label: i18n
SATELLITE:
label: i18n
HYBRID:
label: i18n
TERRAIN:
label: i18n
draggable:
type: boolean
defaultValue: TRUE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'properties'
scrollwheel:
type: boolean
defaultValue: TRUE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'properties'
mapTypeControl:
type: boolean
defaultValue: TRUE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'properties'
zoomControl:
type: boolean
defaultValue: TRUE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'properties'
streetViewControl:
type: boolean
defaultValue: TRUE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'properties'
lat:
type: string
defaultValue: '51.163375'
Expand Down Expand Up @@ -95,6 +154,14 @@
label: '19'
'20':
label: '20'
fitBounds:
type: boolean
defaultValue: FALSE
ui:
label: i18n
reloadIfChanged: TRUE
inspector:
group: 'coordinates'

'ObisConcept.NeosGmaps:MarkerCollection':
superTypes:
Expand Down
16 changes: 13 additions & 3 deletions Resources/Private/Assets/JavaScript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ window.initGoogleMaps = function() {

var map = new google.maps.Map($(this).get(0), {
center: {lat: 0, lng: 0},
zoom: 10
zoom: 10,
mapTypeId: google.maps.MapTypeId[$(this).data('type')],
draggable: $(this).data('draggable'),
scrollwheel: $(this).data('scrollwheel'),
mapTypeControl: $(this).data('map-type-control'),
zoomControl: $(this).data('zoom-control'),
streetViewControl: $(this).data('street-view-control')
});

var infowindow = new google.maps.InfoWindow({
Expand Down Expand Up @@ -65,8 +71,12 @@ window.initGoogleMaps = function() {

}

}

if ($('.google-map-canvas[data-map-id='+id+']').data('fit-bounds') == 1) {

var bounds = new google.maps.LatLngBounds();

for (var i = 0; i < mapMarkers.length; i++) {

bounds.extend(mapMarkers[i].getPosition());
Expand All @@ -90,7 +100,7 @@ window.initGoogleMaps = function() {

});

if (markers.markers.length === 0) {
if ($(this).data('fit-bounds') == 0) {

map.setCenter({lat: $(this).data('lat'), lng: $(this).data('lng')});
map.setZoom($(this).data('zoom'));
Expand Down
6 changes: 4 additions & 2 deletions Resources/Private/Templates/NodeTypes/GoogleMap.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{namespace neos=TYPO3\Neos\ViewHelpers}

<div class="google-map-canvas" data-map-id="{node.identifier}" data-lat="{lat}" data-lng="{lng}" data-zoom="{zoom}" data-markers="<f:format.raw>{</f:format.raw>'markers':[<f:for each="{markers}" as="marker" iteration="iterator"><f:format.raw>{</f:format.raw>'m{iterator.index}':[<f:format.raw>{</f:format.raw>'street':'{marker.properties.street}','zip':'{marker.properties.zip}','city':'{marker.properties.city}','country':'{marker.properties.country}','title':'{marker.properties.title}','text':'<f:format.nl2br>{marker.properties.text}</f:format.nl2br>'<f:format.raw>}</f:format.raw>]<f:format.raw>}</f:format.raw><f:if condition="{iterator.isLast}"><f:then></f:then><f:else>,</f:else></f:if></f:for>]<f:format.raw>}</f:format.raw>" style="height: {height}px;"></div>
<div class="google-map-canvas" data-map-id="{node.identifier}" data-type="{type}" data-draggable="{draggable}" data-scrollwheel="{scrollwheel}" data-map-type-control="{mapTypeControl}" data-zoom-control="{zoomControl}" data-street-view-control="{streetViewControl}" data-lat="{lat}" data-lng="{lng}" data-zoom="{zoom}" data-fit-bounds="{fitBounds}" data-markers="<f:format.raw>{</f:format.raw>'markers':[<f:for each="{markers}" as="marker" iteration="iterator"><f:format.raw>{</f:format.raw>'m{iterator.index}':[<f:format.raw>{</f:format.raw>'street':'{marker.properties.street}','zip':'{marker.properties.zip}','city':'{marker.properties.city}','country':'{marker.properties.country}','title':'{marker.properties.title}','text':'<f:format.nl2br>{marker.properties.text}</f:format.nl2br>'<f:format.raw>}</f:format.raw>]<f:format.raw>}</f:format.raw><f:if condition="{iterator.isLast}"><f:then></f:then><f:else>,</f:else></f:if></f:for>]<f:format.raw>}</f:format.raw>" style="height: {height}px;"></div>

<div class="hidden">{markerCollection -> f:format.raw()}</div>
<f:security.ifAuthenticated>
<div class="hidden">{markerCollection -> f:format.raw()}</div>
</f:security.ifAuthenticated>
48 changes: 46 additions & 2 deletions Resources/Private/Translations/de/NodeTypes/GoogleMap.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,53 @@
<target xml:lang="de" state="translated">Eigenschaften</target>
</trans-unit>
<trans-unit id="groups.coordinates" xml:space="preserve">
<source>Coordinates (ignored when marker set)</source>
<target xml:lang="de" state="translated">Koordinaten (ignoriert, wenn Marker gesetzt)</target>
<source>Coordinates</source>
<target xml:lang="de" state="translated">Koordinaten</target>
</trans-unit>
<trans-unit id="properties.height" xml:space="preserve">
<source>Height in pixels</source>
<target xml:lang="de" state="translated">Höhe in Pixeln</target>
</trans-unit>
<trans-unit id="properties.type" xml:space="preserve">
<source>Map type</source>
<target xml:lang="de" state="translated">Kartentyp</target>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.ROADMAP" xml:space="preserve">
<source>Roadmap</source>
<target xml:lang="de" state="translated">Straßenkarte</target>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.SATELLITE" xml:space="preserve">
<source>Satellite</source>
<target xml:lang="de" state="translated">Satellit</target>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.HYBRID" xml:space="preserve">
<source>Hybrid</source>
<target xml:lang="de" state="translated">Hybrid</target>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.TERRAIN" xml:space="preserve">
<source>Terrain</source>
<target xml:lang="de" state="translated">Gelände</target>
</trans-unit>
<trans-unit id="properties.draggable" xml:space="preserve">
<source>Draggable</source>
<target xml:lang="de" state="translated">Verschiebbar</target>
</trans-unit>
<trans-unit id="properties.scrollwheel" xml:space="preserve">
<source>Scrollwheel zooming</source>
<target xml:lang="de" state="translated">Mausradzoomen</target>
</trans-unit>
<trans-unit id="properties.mapTypeControl" xml:space="preserve">
<source>Map type control</source>
<target xml:lang="de" state="translated">Kartentypsteuerung</target>
</trans-unit>
<trans-unit id="properties.zoomControl" xml:space="preserve">
<source>Zoom control</source>
<target xml:lang="de" state="translated">Zoomsteuerung</target>
</trans-unit>
<trans-unit id="properties.streetViewControl" xml:space="preserve">
<source>StreetView control</source>
<target xml:lang="de" state="translated">StreetView-Steuerung</target>
</trans-unit>
<trans-unit id="properties.lat" xml:space="preserve">
<source>Latitude</source>
<target xml:lang="de" state="translated">Breitengrad</target>
Expand All @@ -29,6 +69,10 @@
<trans-unit id="properties.zoom" xml:space="preserve">
<source>Zoom</source>
<target xml:lang="de" state="translated">Zoom</target>
</trans-unit>
<trans-unit id="properties.fitBounds" xml:space="preserve">
<source>Fit to markers (ignores options above)</source>
<target xml:lang="de" state="translated">An Markern ausrichten (ignoriert vorherige Angaben)</target>
</trans-unit>
</body>
</file>
Expand Down
35 changes: 34 additions & 1 deletion Resources/Private/Translations/en/NodeTypes/GoogleMap.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,41 @@
<source>Height in pixels</source>
</trans-unit>
<trans-unit id="groups.coordinates" xml:space="preserve">
<source>Coordinates (ignored when marker set)</source>
<source>Coordinates</source>
</trans-unit>
<trans-unit id="properties.height" xml:space="preserve">
<source>Height in pixels</source>
</trans-unit>
<trans-unit id="properties.type" xml:space="preserve">
<source>Map type</source>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.ROADMAP" xml:space="preserve">
<source>Roadmap</source>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.SATELLITE" xml:space="preserve">
<source>Satellite</source>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.HYBRID" xml:space="preserve">
<source>Hybrid</source>
</trans-unit>
<trans-unit id="properties.type.selectBoxEditor.values.TERRAIN" xml:space="preserve">
<source>Terrain</source>
</trans-unit>
<trans-unit id="properties.draggable" xml:space="preserve">
<source>Draggable</source>
</trans-unit>
<trans-unit id="properties.scrollwheel" xml:space="preserve">
<source>Scrollwheel zooming</source>
</trans-unit>
<trans-unit id="properties.mapTypeControl" xml:space="preserve">
<source>Map type control</source>
</trans-unit>
<trans-unit id="properties.zoomControl" xml:space="preserve">
<source>Zoom control</source>
</trans-unit>
<trans-unit id="properties.streetViewControl" xml:space="preserve">
<source>StreetView control</source>
</trans-unit>
<trans-unit id="properties.lat" xml:space="preserve">
<source>Latitude</source>
</trans-unit>
Expand All @@ -25,6 +55,9 @@
</trans-unit>
<trans-unit id="properties.zoom" xml:space="preserve">
<source>Zoom</source>
</trans-unit>
<trans-unit id="properties.fitBounds" xml:space="preserve">
<source>Fit to markers (ignores options above)</source>
</trans-unit>
</body>
</file>
Expand Down
16 changes: 13 additions & 3 deletions Resources/Public/JavaScript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ window.initGoogleMaps = function() {

var map = new google.maps.Map($(this).get(0), {
center: {lat: 0, lng: 0},
zoom: 10
zoom: 10,
mapTypeId: google.maps.MapTypeId[$(this).data('type')],
draggable: $(this).data('draggable'),
scrollwheel: $(this).data('scrollwheel'),
mapTypeControl: $(this).data('map-type-control'),
zoomControl: $(this).data('zoom-control'),
streetViewControl: $(this).data('street-view-control')
});

var infowindow = new google.maps.InfoWindow({
Expand Down Expand Up @@ -65,8 +71,12 @@ window.initGoogleMaps = function() {

}

}

if ($('.google-map-canvas[data-map-id='+id+']').data('fit-bounds') == 1) {

var bounds = new google.maps.LatLngBounds();

for (var i = 0; i < mapMarkers.length; i++) {

bounds.extend(mapMarkers[i].getPosition());
Expand All @@ -90,7 +100,7 @@ window.initGoogleMaps = function() {

});

if (markers.markers.length === 0) {
if ($(this).data('fit-bounds') == 0) {

map.setCenter({lat: $(this).data('lat'), lng: $(this).data('lng')});
map.setZoom($(this).data('zoom'));
Expand Down
Loading

0 comments on commit 848c871

Please sign in to comment.