Processwire - Google Maps: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „== Links == * https://github.com/ryancramerdesign/FieldtypeMapMarker == Quickstart == # Modul FieldtypeMapMarker installieren # Feld mit dem neuen Typ MapMarke…“)
 
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 
== Links ==
 
== Links ==
 +
* ALTERNATIV OpenStreetMaps Modul: http://modules.processwire.com/modules/fieldtype-leaflet-map-marker/
 +
* http://modules.processwire.com/modules/fieldtype-map-marker/
 
* https://github.com/ryancramerdesign/FieldtypeMapMarker
 
* https://github.com/ryancramerdesign/FieldtypeMapMarker
 +
* https://processwire.com/talk/topic/9711-map-marker-map/
 +
 
== Quickstart ==
 
== Quickstart ==
 
# Modul FieldtypeMapMarker installieren
 
# Modul FieldtypeMapMarker installieren
Zeile 7: Zeile 11:
 
# Location in einer Seite hinzufügen
 
# Location in einer Seite hinzufügen
 
# Template bearbeiten
 
# Template bearbeiten
== Template bearbeiten ==
+
== Ausgabe ==
 +
=== Mit Rendermethode des Moduls ===
 +
Einfach aber komplizierter zu modifizieren
 
Angenommen das Feld hat den Namen '''map'''
 
Angenommen das Feld hat den Namen '''map'''
  
Zeile 30: Zeile 36:
 
Add this somewhere before your closing `</head>` tag:
 
Add this somewhere before your closing `</head>` tag:
 
`````````
 
`````````
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>
+
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false&key=API_KEY'></script>
 +
 
 
`````````
 
`````````
  
Zeile 100: Zeile 107:
 
---------
 
---------
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
=== Ausgabeskripte manuell ===
 +
Dafür kann man die obenstehenden Variablen nutzen

Aktuelle Version vom 6. April 2017, 14:27 Uhr

Links[Bearbeiten]

Quickstart[Bearbeiten]

  1. Modul FieldtypeMapMarker installieren
  2. Feld mit dem neuen Typ MapMarker erstellen
  3. Feld zu Template hinzufügen
  4. Location in einer Seite hinzufügen
  5. Template bearbeiten

Ausgabe[Bearbeiten]

Mit Rendermethode des Moduls[Bearbeiten]

Einfach aber komplizierter zu modifizieren Angenommen das Feld hat den Namen map

echo $page->map->address;	// outputs the address you entered
echo $page->map->lat; 		// outputs the latitude
echo $page->map->lng; 		// outputs the longitude
echo $page->map->zoom;		// outputs the zoom level
`````````

-------------

## Markup Google Map

This package also comes with a module called MarkupGoogleMap. It provides a simple means
of outputting a Google Map based on the data managed by FieldtypeMapMarker. To install,
simply click "install" for the Google Maps (Markup) module. This is a Markup module, 
meaning it exists primarily to generate markup for output on the front-end of your site.

### How to use

Add this somewhere before your closing `</head>` tag:
`````````
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false&key=API_KEY'></script>

`````````

In the location where you want to output your map, place the following in your template file:
`````````
$map = $modules->get('MarkupGoogleMap'); 
echo $map->render($page, 'map'); 
`````````
In the above, $page is the Page object that has the 'map' field. Rreplace 'map' with the name of 
your FieldtypeMap field

To render a map with multiple markers on it, specify a PageArray rather than a single $page: 
`````````
$items = $pages->find("template=something, map!='', sort=title"); 
$map = $modules->get('MarkupGoogleMap'); 
echo $map->render($items, 'map'); 
`````````

To specify options, provide a 3rd argument with an options array:
`````````
$map = $modules->get('MarkupGoogleMap'); 
echo $map->render($items, 'map', array('height' => '500px')); 
`````````

### Options

Here is a list of all possible options (with defaults shown):  

`width`    
Width of the map (type: string; default: 100%).

`height`    
Height of the map (type: string; default: 300px) 

`zoom`    
Zoom level 1-25 (type: integer; default: from your field settings)

`type`   
Map type: ROADMAP, HYBRID or SATELLITE (type: string; default: from your field settings)

`id`   
Map ID attribute (type: string; default: mgmap)

`class`   
Map class attribute (type: string; default: MarkupGoogleMap)

`lat`   
Map center latitude (type: string|float; default: from your field settings)  

`lng`   
Map center longitude (type: string|float; default: from your field settings)

`useStyles`   
Whether to populate inline styles to the map div for width/height (type: boolean; default: true).
Set to false only if you will style the map div yourself.

`useMarkerSettings`   
Makes single-marker map use marker settings rather than map settings (type: boolean; default: true).

`markerLinkField`   
Page field to use for the marker link, or blank to not link (type: string; default: url).

`markerTitleField`    
Page field to use for the marker title, or blank not to use a marker title (type: string; default: title). 

`fitToMarkers`   
When multiple markers are present, set map to automatically adjust to fit to the given markers (type: boolean; default: true). 

---------

Ausgabeskripte manuell[Bearbeiten]

Dafür kann man die obenstehenden Variablen nutzen