public function index() { $marker = array(); # show map google $config = array(); $config['center'] = 'auto'; $gmaps = new Gmaps(); $gmaps->initialize($config); // set up the marker ready for positioning // once we know the users location if (Auth::guest()) { $maps_crops = Crops::all(); } else { if (Auth::user()->typeuser_id == '2') { $maps_crops = Crops::all(); } else { $maps_crops = DB::table('group_crop_users')->join('crops', 'group_crop_users.crop_id', '=', 'crops.crop_id')->where('group_crop_users.user_id', '=', Auth::user()->id)->get(); } } foreach ($maps_crops as $map) { // Loop Create Map $marker['map_id'] = $map->crop_id; $marker['position'] = $map->crop_latitude . ',' . $map->crop_longitude; $marker['title'] = 'mapid_' . $map->crop_id; $marker['icon'] = 'assets/img/crops/rice/rice_running.png'; $gmaps->add_marker($marker); } $map = $gmaps->create_map(); return view('home', compact('map')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id, Phpgmaps $gmpas) { $service = Service::findOrFail($id); $config['center'] = $service->lat . ', ' . $service->lng; $config['zoom'] = 15; $gmpas->initialize($config); $marker = []; $marker['position'] = $service->lat . ', ' . $service->lng; $gmpas->add_marker($marker); $map = $gmpas->create_map(); return view('services.show')->with('map', $map)->with('service', $service)->with('title', $service->name); }
public function index() { # show map google $config = array(); $config['center'] = 'auto'; $config['onboundschanged'] = 'if (!centreGot) { var mapCentre = map.getCenter(); marker_0.setOptions({ position: new google.maps.LatLng(mapCentre.lat(), mapCentre.lng()) }); } centreGot = true;'; $gmaps = new Gmaps(); $gmaps->initialize($config); // set up the marker ready for positioning // once we know the users location $marker = array(); $marker['position'] = '14.077874, 100.601791'; $gmaps->add_marker($marker); $map = $gmaps->create_map(); return view('home', compact('map')); }