Search the Community
Showing results for tags 'mapmarker'.
-
Hi Folks, Encountered strange problem re: PageReference + MapMarker. The PageReference is being used for creating "tags" ala @renobird from this comment here: ( thx renobird! ) I then have a template with the PageReference on it, then below that a simple and standard MapMarker. If i set the Page Reference to "Allow New Pages Created", it's great, new tags can be added in. But when you then tab into the MapMarker and set the location all appears fine until you either Save Page or Publish. At that point, the page is saved, the new tags are added correctly, but No Location is saved in the Map Marker. If I set the Page Reference to NOT "Allow New Pages Created", the MapMarker location is saved perfectly well. So does anyone know if something weird happens in the "Save", that successfully adds in the new tags, but looses what was put into the MapMarker location ? Thx!
-
Resources (Ryan's own): ImportPagesCSV FieldtypeMapMarker So I edit the accepted $fieldtypes on :76: /** * List of Fieldtypes that we support importing to * */ protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePage', 'FieldtypeMapMarker', 'FieldtypePassword', 'FieldtypeRepeater' ); Page, MapMarker, Password and Repeater were added by me. Then alter importPageValue: /** * Assign a value to a page field * */ protected function importPageValue(Page $page, $name, $value) { $field = $this->fields->get($name); if($field->type instanceof FieldtypeFile) { $value = trim($value); // split delimeted data to an array $value = preg_split('/[\r\n\t|]+/', $value); if($field->maxFiles == 1) $value = array_shift($value); $data = $page->ImportPagesCSVData; $data[$name] = $value; $page->ImportPagesCSVData = $data; } elseif($field->type instanceof FieldtypePage) { $value = trim($value); if(wire("pages")->find("$name=$value")) $page->set($name, $value); } elseif($field->type instanceof FieldtypeMapMarker) { $value = trim($value); $page->set($name->address, $value); } elseif($field->type instanceof FieldtypeRepeater) { // } else { $page->set($name, $value); if($name == 'title') $page->name = $this->sanitizer->pageName($value, 2); // Sanitizer::translate elseif($name == 'fullname') { $page->name = $this->sanitizer->pageName($value, true); } } } Page import works with ID values, which was trivial to incorporate; passwords too. MapMarker and Repeater as you might guess do not. How can I save the map->address value? Hopefully it will update the corresponding map fields too but one thing at a time. As for the repeaters... LostKobrakai tipped me off to foreach($page->engines as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } which works for their names and values, but in this function you're passed the field, and something like foreach($page->$field as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } doesn't work... and what it would need to do inside anyway is check for a subfield whose name is equal to the column header (choose the repeater field itself e.g., engines in the select per repeater subfield value, e.g., engine_fueltype), then explode that cell value by pipes ('|'), and for each subvalue, populate the repeater#->subvalue... but before all that I need to be able to iterate through the subfields from the field in this function. Anyone have any ideas?
-
I have an importer function that goes like this so far function importCSV($filepath, $template, $parent_id = null, $grandparent_id = null) { $csv = array_map('str_getcsv', file($filepath)); array_walk($csv, function(&$a) use ($csv) { $a = array_combine($csv[0], $a); # set header keys }); array_shift($csv); # remove column header //echo '<pre>'; print_r($csv); echo '</pre>'; foreach($csv as $r) { $p = new Page(); $p->name = wire('sanitizer')->pageName($r['title']); $p->template = $template; if($parent_id !== 0||null) { $p->parent_id = $parent_id; } elseif($parent_id == 0||null) { //echo $r['parent'].' '; $parent = wire('sanitizer')->pageName($r['parent']); $parent = str_replace('---','-',$parent); //echo $parent.' ';//echo $grandparent_id.'gp '; $parent = wire('pages')->get('title=' . $r['parent'] . ', parent_id=' . $grandparent_id)->id; //echo $parent.'p '; $p->parent_id = $parent; unset($r['parent']); } $p->save(); var_dump($r); foreach($r as $k=>$v) { $fieldtype = wire('fields')->get('name='.$k)->type; echo $fieldtype.' '; if($fieldtype->name == 'FieldtypeImage') { $imgs = explode('|', $v); foreach($imgs as $i) { $p->$k = $i; } } elseif($fieldtype->name == 'FieldtypeMapMarker') { echo 'mapmarker'; $p->set($k->address, $v); } else $p->$k = $v; } $p->save(); echo '<br><br>'; } } It reads the field as being a MapMarker but does not input the address data?
-
Hey folks, I'm looking to implement the Google Maps Store Locator library to create a "Find Locations Near You" page for my site. I'm using the MapMarker fieldtype to create my locations, but I'm not sure how to connect my location data to the storeLocator.DataFeed The examples provided for the Store locator fetch data from static CSV files or web services. Any thoughts on how to hook things up? Thanks so much!
-
Im having troubles to make this work; for some reason on the admin area i can set my market fine; but when i render the map y de frontend the marker just go difrent from i save. I dont see why the module is making the marks in drifrent location from save on the db. Edit1: when i change the map to hybrid mode the market show in the right location; but if i switch to roadmap the cursor move from the location. $markers = $page->children(); $map = $modules->get('MarkupGoogleMap'); print $map->render($markers, 'field_map', array('type' => 'ROADMAP'));
- 3 replies
-
- Marker
- googleMaps
-
(and 3 more)
Tagged with: